Page 1 of 1

Searching a text field

Posted: Wed Jul 10, 2002 10:05 pm
by chris12295
i need an effective way to search a text field in a database for a keyword, ive tried LIKE but it doesnt match unless someone types the exact contents and if u put LIKE %$var% it matches down to letters which isnt very relevant. i need to match words, can anyone help?

Posted: Thu Jul 11, 2002 4:28 am
by Wayne
This should work :

Code: Select all

SELECT mycolumn FROM mytable WHERE mycolumn RLIKE "&#1111;&#1111;:<:]]$var&#1111;&#1111;:>:]]"

Posted: Thu Jul 11, 2002 8:15 am
by jason
You can also avoid the Regular Expressions and just use this:

Code: Select all

SELECT field FROM table WHERE field LIKE '% word %'
Notice the spaces around 'word'.

Posted: Thu Jul 11, 2002 8:29 am
by Wayne
that will work provided the word is not preceeded or followed by any punctuation or end of string markers.