我有一个短语表:
buy car
adopt cute cat
make big money
buy helicopter
big nasty dog
带有FULLTEXT索引。我想找到在给定文本中完全出现的所有短语。
对于文字:
I want to buy car and then buy and adopt cute cat tomorrow.
我应该得到:
buy car
adopt cute cat
我尝试过查询:
SELECT * FROM `phrases` WHERE MATCH(`phrase`) AGAINST('I want to buy car and then buy and adopt cute cat tomorrow.' IN BOOLEAN MODE)=`numWords`
但那给了我
buy helicopter //since there are twice "buy" and the number of total words is 2
adopt cute cat
提前致谢。
答案 0 :(得分:0)
只需在查询中添加AND phrases LIKE '%I want to buy car and then buy and adopt cute cat tomorrow.%'
即可。它将使用FULLTEXT键快速查找匹配项,然后对结果进行后置过滤,以确保短语列中存在完全匹配的短语。