我想显示结果,以便行具有更多匹配项应该排在顶部。
就像我在标题和内容中搜索关键字"abc"一样,它会计算每行标题和内容中"abc"的总匹配项。
假设它找到了
第一排3场比赛,
第二排5场比赛,
第 3 行 2 场比赛
然后结果将首先显示 5 个匹配行,之后 3 匹配行,依此类推,按 DESC 顺序排列
我使用了这个查询,但它没有对正确的结果进行排序。
SELECT title, MATCH(title, content) AGAINST ('>("abc def") (abc def) <(abc* def*)' IN BOOLEAN MODE) AS relevance
FROM articles_template
WHERE 1=1
AND MATCH(title, content) AGAINST ('>("abc def") (abc def) <(abc* def*)' IN BOOLEAN MODE)
AND date BETWEEN '2015-02-18 00:00:00' AND '2016-02-18 00:00:00'
ORDER BY relevance DESC
LIMIT 0,10
select count(title) as count from table_name group by title order by count