Complicated database querys
Greetings!
I am trying to query my database through php but its starting to get real complicated. This is the setup: a user visits page1.php to search for a name in the database. I want the user to be able to search for this name by user name, first name or last name. Say they type in "John Smith" into the form...
The script then querys the database: SELECT * FROM users WHERE ((username LIKE '%John%') OR (firstname LIKE '%John%') OR (lastname LIKE '%John%')) OR ((username LIKE '%Smith%') OR (firstname LIKE '%Smith%') or (lastname LIKE '%Smith%'))
So I'm wondering is there an easier way to query the database and get the same results? I am planning to use another search for business names where users might type in more than two words and I would hate for the query to get any more complicated than it already is.
Many thanks in advance!
- e.ruckus