Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to search on more than one field using LIKE

Status
Not open for further replies.

Mayoor

Programmer
Jan 16, 2004
198
GB
Can anyone help with the syntax?

So far I have

SELECT * FROM nsc_community WHERE users LIKE %Mike

however I'd like to also search the desription field as well. Would it be as simple as separating the field names with a comma?
 
i am not sure i understand.
if you want to filter on nsc_community and description fields:

SELECT * FROM nsc_community WHERE users LIKE '%Mike%' and description like '%california%'
 
OK basically the user will enter a search string, and the SQL statement must look in several fields for that string.

Mayoor
 
Also is there any way i can use a wildcard to represent every field in the database?
 
Try this:
SELECT * FROM nsc_community WHERE users LIKE '%Mike%' OR description like '%Mike%'

This will search both fields for occurances of '%Mike%'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top