Another SQL Question: Search Function

Hello Friends,

I am working on a search function for a site I’m making…

What I’m trying to do is allow users to search through a database full of music reviews, articles, news, message board posts, etc. However, when I try it using a mysql query like SELECT * FROM reviews WHERE post=’(what they searched for)’ it only returns results where the post field in the database EXACTLY matches what they search for. I need them to be able to type in like “Eric Clapton” and it will return all results that say Eric Clapton anywhere in them. So it searches the fields I tell it to, and wherever it says Eric Clapton in a field along with other text (not just a field that says Eric Clapton) it will return as a result to that search.

Any help would be great.

Thanks,

Nick

Check out out the keyword LIKE and full text searches.

References:
http://dev.mysql.com/doc/mysql/en/Fullt … uning.html
http://dev.mysql.com/doc/mysql/en/Strin … tions.html

Thank you!!

-Nick

Sponsor our Newsletter | Privacy Policy | Terms of Service