2011-07-13 81 views
0

我有這個目前SQL查詢兩列匹配:必須在布爾模式

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

但是我找回行,如果他們匹配任何一種htext或關鍵字...我想關鍵字必須匹配在htext和關鍵字中。我也有問題,實際上按照相關性在MySQL 5.1中排序5.1

回答

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