[thelist] mysql - like

Max Schwanekamp lists at neptunewebworks.com
Thu Aug 24 03:49:21 CDT 2006


> From: Chris Price
> The next thing is searching on phrases so that if a search is made on
'this word' results are
> returned for 'this' or 'word'. Do you know any good resources for this
stuff.

Either use LIKE clauses or perhaps better, use fulltext searching, e.g.:

SELECT *, 
  MATCH(myCol) AGAINST ('this word') AS 'match_score'
FROM myTbl 
WHERE MATCH(myCol) AGAINST ('this word')
ORDER BY match_score DESC

(Though IIRC, 'this' is a stopword, i.e. MySQL ignores it in fulltext
searches, but I guess you just used it as a dummy value).

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

-- 
Max Schwanekamp
NeptuneWebworks.com






More information about the thelist mailing list