0
我在我的分贝中有成分表。我想获取那些含有一些成分但不含某些成分的食谱。全文搜索查询mysql
例如,我有两个食谱都包含“pav”,但其中一个不包含“phudina”。现在,下面是我的数据库表数据。
Here in table(ingredients) recipeID 24(rcteID) contains pav and phudina
-----------------------------------------------------------------------
ingredientID rcteID ingredient
319 24 phudina
320 24 pav
Here in table(ingredients) recipeID 23(rcteID) not contains phudina
-----------------------------------------------------------------------
ingredientID rcteID ingredient
316 23 test
317 23 pav
318 23 puri
现在我希望这些配方IDS包含“PAV”,而不是“phudina”所以,在这里它是23,但我的查询是给我两个食谱。我已经在成分栏中应用了全文索引。
Below is the query which I have written.
SELECT `Ingredient`.`ingredientID`, `Ingredient`.`rcteID`
FROM `bdrplus`.`ingredient` AS `Ingredient`
WHERE NOT(MATCH(`Ingredient`.`ingredient`) AGAINST('+phudina' IN BOOLEAN MODE))
AND MATCH(`Ingredient`.`ingredient`) AGAINST('+pav' IN BOOLEAN MODE)
GROUP BY `Ingredient`.`rcteID
Output
----------------------------
ingredientID rcteID
317 23
320 24
Expected
-----------------------------
ingredientID rcteID
317 23
查询有什么问题?
为什么在只包含单个单词的列上使用全文搜索? – Barmar 2014-12-04 10:17:59