Jump to content

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'

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.