查詢1:這兩個SQL查詢有什麼區別?
SELECT Frequents.drinker FROM Frequents
WHERE Frequents.drinker NOT IN (
SELECT F.drinker FROM Frequents AS F
WHERE F.bar NOT IN
(
SELECT bar FROM Sells, Likes WHERE Sells.beer = Likes.beer AND Likes.drinker = F.drinker
)
)
QUERY 2:
SELECT Frequents.drinker FROM Frequents, Sells, Likes
Where Frequents.drinker = Likes.drinker and Sells.bar IN(
SELECT bar from Sells where Sells.beer = Likes.beer)
關係模式
注:忽略拼寫錯誤。
其中上述查詢的是正確的「打印飲水服務於一些啤酒,他們喜歡 經常只吧。(假設每個 飲酒喜歡至少一個啤酒流連至少一個吧。)」
Q1是分配的解決方案,Q2是我提交的內容,我相信我的查詢版本是正確的。 –