Suppose I have two columns, keywords and content. I have a fulltext index across both. I want a row with foo in the keywords to have more relevance than a row with foo in th
I needed something similar and used the OP's solution, but I noticed that fulltext doesn't match partial words. So if 'watermelon' is in Keywords or Content as part of a word (like watermelonsalesmanager) it doesn't MATCH and is not included in the results because of the WHERE MATCH. So I fooled around a bit and tweaked the OP's query to this:
SELECT *,
CASE WHEN Keywords LIKE '%watermelon%' THEN 1 ELSE 0 END AS keywordmatch,
CASE WHEN Content LIKE '%watermelon%' THEN 1 ELSE 0 END AS contentmatch,
MATCH (Title, Keywords, Content) AGAINST ('watermelon') AS relevance
FROM about_data
WHERE (Keywords LIKE '%watermelon%' OR
Title LIKE '%watermelon%' OR
MATCH(Title, Keywords, Content) AGAINST ('watermelon' IN BOOLEAN MODE))
HAVING (keywordmatch > 0 OR contentmatch > 0 OR relevance > 0)
ORDER BY keywordmatch DESC, contentmatch DESC, relevance DESC
Hope this helps.