Rank SQL full text query by relevance in boolean mode

  • 3/31/2011

Assuming that $keywords holds the query keywords, a table containing the indexed columns title and body may be queried for relevant results using:

SELECT mytable.*, MATCH(title,body) 
AGAINST('$keywords') AS relevance 
FROM `mytable` 
WHERE MATCH(title,body) AGAINST('$keywords' IN BOOLEAN MODE) 
ORDER BY relevance DESC```