sloth456 Posted February 10, 2009 Share Posted February 10, 2009 Ok. Sorry if this has been asked before. I have a MYSQL database with just one column. This is what it has in it. blue yellow bluething blue thing thingblue I want to search this column for "blue" and have it return not just the first row, but any other column that contains the string "blue" anywhere within it. So it would return all those rows except "yellow". Just doing a WHERE statement will only return an exact match. Doing a LIKE statement would be better but wouldn't that only return "blue","blue thing" and "bluething" and not "thing blue"? Hope someone can help. Link to comment https://forums.phpfreaks.com/topic/144588-solved-doing-a-deep-search-through-mysql/ Share on other sites More sharing options...
gaza165 Posted February 10, 2009 Share Posted February 10, 2009 The best thing would be to do is try it and see what results you get back. <?php $query = mysql_query("SELECT * FROM table_name WHERE column_name LIKE '%blue%'"); ?> This will search the column for strings that contain the characters 'blue' Link to comment https://forums.phpfreaks.com/topic/144588-solved-doing-a-deep-search-through-mysql/#findComment-758762 Share on other sites More sharing options...
sloth456 Posted February 10, 2009 Author Share Posted February 10, 2009 Aha! so that's how to use the LIKE statement properly. Thanks, that works really well. Link to comment https://forums.phpfreaks.com/topic/144588-solved-doing-a-deep-search-through-mysql/#findComment-758787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.