Enrique Sanchez Vela wrote:
John,

using  'one.*two|two.*one' would do it. :)

regards,
esv.

That will work, but doesn't generalize very well. Imagine how that will look with 4 or 5 search terms.

LIKE and REGEXP are meant to match strings, not find words. They are ill-suited to finding matches where the order of the words in the search string is not important. Ususally this is done with a full-text index, but it can be done with REGEXP if you change your approach.

The requirement is find rows which match several required search strings. The simple solution is to write each required search string as a separate condition, rather than trying to write one complicated, ugly regular expression. Thus, I'd suggest:

  SELECT * FROM tbl
  WHERE item REGEXP 'SAMSUNG'
    AND item REGEXP '40GB';

With more search terms, you'd simply add another regexp for each.

Michael

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

Reply via email to