refiking Posted May 30, 2009 Share Posted May 30, 2009 How can I write a query to search for any records where the value for a field contains a certain string. $string = 'jest'; //$sql = mysql_query("select `desc` from `jokes` where `item_name` contains $string"); Link to comment https://forums.phpfreaks.com/topic/160291-search-for-string-in-a-db-field/ Share on other sites More sharing options...
Michdd Posted May 30, 2009 Share Posted May 30, 2009 Is it a partial string? Could it possibly contain something before and after? If so use this: $sql = mysql_query("select `desc` from `jokes` where `item_name` LIKE '%$string%'"); Link to comment https://forums.phpfreaks.com/topic/160291-search-for-string-in-a-db-field/#findComment-845893 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.