Page 1 of 1

Query part of a MySQL return

Posted: Fri May 26, 2006 11:15 pm
by Jr
Ok, I think my brain is officially off being memorial day weekend or something but I'm trying to do a simple database query but I want to search through the query results to see if all or "part" of the results match my query. I can get the "all" part with a normal query (like below) but how do I search to see if only part of the retults match?


$my_link_query = mysql_query( "SELECT * FROM mydb WHERE link_name='$query'" );

Thanks,
Jr-

Posted: Fri May 26, 2006 11:46 pm
by bdlang
Possibly using LIKE:

Code: Select all

SELECT
 somefield
, someotherfield
FROM sometable
WHERE searchfield LIKE '%{$query}%'
;
Essentially returns records with `searchfield` that matches characters before or after the search string.

MySQL Manual: String Comparison Functions