is it ok to use and or in a clause (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


pintofale -> is it ok to use and or in a clause (1/22/2008 14:26:36)

I am building a search form for an access db and have a statment which uses and/or statments in the clause. I am not sure if the syntax is correct or not. Any help or pointers would be great.

this is the statement:

Set rs = Conn.Execute("SELECT id, subject,  firstname FROM notes WHERE subject LIKE '%%& Request.form("lastname") &%%' OR firstname LIKE '%%& Request.form("firstname") &%%' OR subject LIKE '%%& Request.form("lastname") &%%' AND firstname LIKE  '%%& Request.form("firstname") &%%'")




rdouglass -> RE: is it ok to use and or in a clause (1/23/2008 8:16:52)

quote:

Set rs = Conn.Execute("SELECT id, subject, firstname FROM notes WHERE subject LIKE '%%& Request.form("lastname") &%%' OR firstname LIKE '%%& Request.form("firstname") &%%' OR subject LIKE '%%& Request.form("lastname") &%%' AND firstname LIKE '%%& Request.form("firstname") &%%'")


How about this way:

Set rs = Conn.Execute("SELECT id, subject, firstname FROM notes WHERE ((subject LIKE '%" & Request.form("lastname") & "%') OR (firstname LIKE '%" & Request.form("firstname") & "%')) OR ((subject LIKE '%" & Request.form("lastname") &" %') AND (firstname LIKE '%" & Request.form("firstname") &" %'))")

Something like that?




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625