MYSQL Search question
Posted: Fri Jun 25, 2010 11:44 am
First off let me just say that I'm rather new at MYSQL and PHP.
My question is, what would be the best way to search a single column in a DB that contains multiple words separated by spaces?
My current SQL statement looks something like this
txtsearch is a column name in my DB and $txtsearch is the variable for the search box.
Is there a better way to go about this?
Right now I'm getting way to many results when I search.
For example, if I search for the word Deli I will receive 25 different rows and only 3 of those rows actually have the word Deli in them. It's almost like it's searching for each individual character and not the entire word.
Any help would be appreciated.
My question is, what would be the best way to search a single column in a DB that contains multiple words separated by spaces?
My current SQL statement looks something like this
Code: Select all
$q = mysql_query("Select * from tbl_restaurantinfo Where txtsearch Like '%". $txtsearch. "%' Order By name");Is there a better way to go about this?
Right now I'm getting way to many results when I search.
For example, if I search for the word Deli I will receive 25 different rows and only 3 of those rows actually have the word Deli in them. It's almost like it's searching for each individual character and not the entire word.
Any help would be appreciated.