Thursday, 29 August 2013

Search across multiple columns

Search across multiple columns

I'm using this Mysql query:
WHERE fname LIKE '%{$query}%' OR lname LIKE '%{$query}%' OR zipcode LIKE
'%{$query}%' OR city LIKE '%{$query}%'
Let's say I have the following info in my database:
First Name: Bill
Last Name: Gates
Zipcode: 12345 AA
City: New York
When I search for 'New York', I get the expected result (bill gates), But
when I search for "bill new york' I get no results.
What is the correct query to search across multiple columns?

No comments:

Post a Comment