必须在布尔模式下匹配两列

时间:2011-07-13 04:44:20

标签: mysql

我目前有这个SQL查询:

SELECT htext FROM paragraphs WHERE MATCH(htext, keywords)
AGAINST('+genomics' IN BOOLEAN MODE) ORDER BY MATCH(htext)
AGAINST('+genomics' IN BOOLEAN MODE)desc

然而,如果它们在EITHER htext或关键字中匹配,我将返回行...我希望关键字必须在htext AND关键字中匹配。我也有问题实际上按照mysql 5.1中的相关性排序

1 个答案:

答案 0 :(得分:0)

SELECT htext,  MATCH(htext) AGAINST('+genomics' IN BOOLEAN MODE) AS Relevance FROM paragraphs 
WHERE MATCH(htext) AGAINST('+genomics' IN BOOLEAN MODE) 
AND MATCH(keywords) AGAINST('+genomics' IN BOOLEAN MODE)
ORDER BY Relevance DESC