refining search query
Posted: Thu Aug 04, 2005 12:45 pm
This is probably a very simple problem, but i can't think what to search for to get an answer without just asking...here goes
I'm selecting entries from my database based on the user's entry in to a form field named 'businesstype'. My query goes somehing like this:
My question is, how can I structure the query to select any business that contains the user's search term only as a distinct word in the 'Type' field?
For example, if the user enters 'car', the results should include 'car dealers', but not 'caravan sites'.
I'm selecting entries from my database based on the user's entry in to a form field named 'businesstype'. My query goes somehing like this:
Code: Select all
$query = ("SELECT * FROM business_directory WHERE Type LIKE '%$businesstype%'");For example, if the user enters 'car', the results should include 'car dealers', but not 'caravan sites'.