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