Reputation: 16244
I have a table in which there are three fields
1. city
2. name
3. country
I am available with auto suggest in single Search field as comma seperated values for above given three fields, Now when I write anything on Text field of search and click search i must get all relevant resault. But my query seems to wrong as
I have writtent the WHERE clause as
SELECT * FROM mytable WHERE city LIKE '%$xyz%' OR name LIKE '%$xyz%' OR country LIKE '%$xyz%'
NOTE: while giving input in the search field I DO NOT SELECT ANY AUTOSUGGESTED VALUE
Please Help me to Rectify my query
Upvotes: 0
Views: 106
Reputation: 11
SELECT *
FROM mytable
WHERE name like '%$name%' OR country like '%$country%' OR city like '%$city%'
Upvotes: 0
Reputation: 1357
You need single quotes in your LIKE clauses:
SELECT * FROM mytable WHERE city LIKE '%$xyz%' OR name LIKE '%$xyz%' OR country LIKE '%$xyz%'
Upvotes: 1