我有這個表:SQL查詢沒有顯示正確的數據
Recipe = (idR, recipeTitle, prepText, cuisineType, mealType)
Ingredient = (idI, ingrDesc)
RecipIngr = (idR*, idI*)
,我試圖顯示IDR和包含的成分蜂蜜或芥末配方標題。這是我的查詢
select idr, recipetitle
from recipe
where idr IN (select idr from recpingr where idi =
(select distinct idr from ingredient where ingrdesc like '%honey%'))
INTERSECT
select idr, recipetitle
from recipe
where idr IN (select idr from recpingr where idi =
(select distinct idr from ingredient where ingrdesc like '%mustard%'))
ORDER BY idr;
由於某種原因,這將不會顯示正確的數據,我不知道我做錯了什麼。任何幫助?我的查詢有問題嗎?
請告訴我們一些示例數據,您的查詢的結果,你爲什麼會認爲「正確」的數據。理想情況下在http://sqlfiddle.com –