Forums

This topic is locked

SQL query with OR on multiple fields

Posted 06 Nov 2007 20:45:26
1
has voted
06 Nov 2007 20:45:26 mark mark posted:
Hello,

I am trying to write a fairy simple SQL query on my ACCESS linked .ASP page that will search through several (more than 1) JobPosting fields for keywords. I have tried this :

FROM JobPostings
WHERE JobState = MMColParam AND [JobTitle,MajDuties,ReqSkills] like '%MMColParam2%'
ORDER BY JobTitle ASC

to no avail. Note:

JobPosting table has the following fields:
JobTitle, MajDuties,ReqSkills,JobState...etc

and MMColParam is a form passed variable detailing the state the user picks and MMColParam2 is a form passed keyword.

Can anyone help me? Maybe the syntax for using OR and AND clauses?


Replies

Replied 13 Nov 2007 16:16:19
13 Nov 2007 16:16:19 Seb Adlington replied:
Hi Mark,

You need to specify the fields. Try:

FROM JobPostings
WHERE JobState = MMColParam AND (JobTitleMaj like '%MMColParam2%' OR Duties like '%MMColParam2%' OR
ReqSkills like '%MMColParam2%' )
ORDER BY JobTitle ASC

Cheers

Seb

Reply to this topic