Page 1 of 1

testing multiple conditions with like

Posted: Sun Sep 11, 2011 5:34 am
by timoteo
Hi everyone,
I'm looking how to match a name field with 2 database columns

Code: Select all

SELECT id FROM username WHERE firstname LIKE %john% OR %smith% OR firstname IN ('john smith') AND lastname LIKE %john% OR %smith% OR lastname IN ('john smith')
Is this correct? I can't get a match on the second word. (smith) only on john. How can I get a match on the second word as well?
Thanks for any help.

Re: testing multiple conditions with like

Posted: Sun Sep 11, 2011 5:45 am
by timoteo
resolved:
firstname LIKE %john% OR firstname LIKE %smith%...