View Single Post
  #1 (permalink)  
Old Feb 1st, 2008, 23:03
linchpin311 linchpin311 is offline
Junior Member
Join Date: Mar 2007
Location: Long Island, NY
Age: 23
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to linchpin311
Question 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 im 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!
- Linchpin
Reply With Quote