Jump to content

[SOLVED] Doing a deep search through MYSQL


sloth456

Recommended Posts

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.

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'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.