Page 1 of 1

Search database for part of a text input

Posted: Sun Oct 30, 2005 4:49 pm
by Tehquickness
Lets say i had a database of member information and I wanted to search the name field for 'Ryan' to find all the Ryans regardless of the last name.
what would be the mysql query to do that with?
I was thinking it would be

Code: Select all

SELECT * FROM members_page WHERE name = 'ryan *';
or something close but no combination of that i have tried seems to work for me.

Posted: Sun Oct 30, 2005 4:52 pm
by Chris Corbyn

Code: Select all

SELECT * FROM members_page WHERE name like 'ryan%'

Posted: Sun Oct 30, 2005 5:08 pm
by Tehquickness
awesome that works perfectly. Am i correct to assume that the % is a wildcard? and if that is the case i could also use it like %word% to search for something with text on both sides
EX

%gath%

would find

Ryan Gathmann
and
Ryan gathster

Posted: Sun Oct 30, 2005 5:19 pm
by Chris Corbyn
Very true indeed :)

You could always try it ;)