stone.cold.steve.austin Posted August 19, 2006 Share Posted August 19, 2006 Hi,Suppse I have a column in my database called Description with the the following rows in the coumn:I am an artistI am an art teacherand 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.thanksRichard Link to comment https://forums.phpfreaks.com/topic/18055-question-regarding-the-like-statement/ Share on other sites More sharing options...
fenway Posted August 20, 2006 Share Posted August 20, 2006 Well, you can use a REGEXP match, and add word boundaries. Link to comment https://forums.phpfreaks.com/topic/18055-question-regarding-the-like-statement/#findComment-77416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.