Jump to content

question regarding the like statement


stone.cold.steve.austin

Recommended Posts

Hi,
Suppse I have a column in my database called Description with the the following rows in the coumn:

I am an artist
I am an art teacher

and i want to check to see if any of the rows in that column contain the word "art" - art as its own word, not as part of a word.

so i use this peiece of code to find the records that have art and print them to the page:

$query = "select Description from TableName where (Description like '%art%')";
while ($row = @mysql_fetch_array($query , MYSQL_ASSOC)) {
  print $row{'Description'} . "<br>";
}

however the above code with the like statement returns both the records, where as I only want to return the second record that has "art" - as its a match for a whole word in that row, not as part of a word (ie. the like statement sees "art" as a match with "artist", but i dont want it too.

am i making sense? if so, can the above code be modified too do what i want.

thanks
Richard
Link to comment
Share on other sites

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.