Forum Moderators: open

Message Too Old, No Replies

Help with Access and Asp Query

         

BlackRaven

7:23 pm on Feb 2, 2005 (gmt 0)

10+ Year Member



hi, quick ques, i called a access db and everything works but having some problems in my query, the thing is i cant seem to figure y my AND School is not working . I mean it shows the reults by doesnt refine it accouring to the school field.

THank you

strSQL = "SELECT * FROM Books WHERE Title LIKE '%" & Search & "%' OR Author LIKE '%" & Search & "%' OR CourseCode LIKE '%" & Search & "%' OR ISBN LIKE '%" & Search & "%' AND school LIKE '%" & schoolsearch & "%' ORDER BY Date DESC;"

too much information

7:26 pm on Feb 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try using ()'s

SELECT * FROM Books WHERE (Title LIKE '%" & Search & "%' OR Author LIKE '%" & Search & "%' OR CourseCode LIKE '%" & Search & "%' OR ISBN LIKE '%" & Search & "%') AND school LIKE '%" & schoolsearch & "%' ORDER BY Date DESC;

BlackRaven

9:37 pm on Feb 2, 2005 (gmt 0)

10+ Year Member



hi, thanks got it working but ran into another problem, say suppose i want to specify the school field which has a blank value. The thing is i just added the school field and my default value for that particular school is blank.

too much information

2:19 pm on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the value is blank you can use the value 'NULL' (without the quoted) and it should work.