Scott Klarenbach wrote:
I have a client that wants to search table fields for strings, and
ignore any-non alphanumeric character in the field. (match only the
alphanumeric portion of the field, and discard the rest)

for example, a search for apple would return true on the following record

a**__-p p   + l ^^   @e


Have you tried padding the characters of the search word with for instance [^a-z0-9]*? Something like this if you are using PHP:


$q = "SELECT * FROM TAB1 WHERE searchword REGEXP ".
  implode('[^a-z0-9]*',
    preg_split('//', "'$searchword'", -1,
    PREG_SPLIT_NO_EMPTY));

The result should be:

SELECT * FROM TAB1 WHERE searchword REGEXP '[^a-z0-9]*a[^a-z0-9]*p[^a-z0-9]*p[^a-z0-9]*l[^a-z0-9]*e[^a-z0-9]*'

Any index on 'searchword' will of course not be used.

--
Roger


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to