mysql:与max进行匹配并进行查询
我有以下查询
选择*,匹配(标题,文本)反对('我的家'在布尔模式)作为相关性从blog
其中active
= 1
上述查询返回5行,相关性为2,2,0,0,0
现在我只想选择具有最大相关性的行。 所以它应该只返回具有2的相关行。
我尝试了下面的查询。
选择*,匹配(标题,文本)反对('我的家'在布尔模式)作为相关性从blog
其中active
= 1具有相关性=最大(MATCH(标题,文本)反对('我的家'布尔模式))
但它只返回一行..
有没有办法只得到这两行?
SELECT *, MATCH(title,text) AGAINST('my home' in boolean mode) as relevance
FROM blog
where active = 1
and MATCH(title,text) AGAINST('my home' in boolean mode) = (select max(MATCH(title,text) AGAINST('my home' in boolean mode)) from blog)
链接地址: http://www.djcxy.com/p/75339.html