faqts : Computers : Databases : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

48 of 64 people (75%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How would I create the syntax for this query? select foobar like '%brown, charley%', If you actually search "charley brown"? When the db is reversed?

Feb 11th, 2008 01:01
dman, Adam Cripps, Christian Mack, Tõnu Samuel, Patrick Hanf, http://sturly.com


Do you want to get answer even if order of names is reversed? In this
case correct clause is 
SELECT * FROM table WHERE foobar LIKE '%brown%'AND foobar LIKE 
'%charley%'


_________________________________________________________________________
You would also want to store charley and brown in two different fields -
for example 
first_name and second_name- then search across the two - returning any
records 
which match either -this method allows the user to enter either in
either field and you 
will still get a return.

HTH

Adam
_________________________________________________________________________