我见过很多模棱两可的问题,尝试了很多东西,仍然不起作用

n9vozmp4  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(242)

我想知道,为什么在这种情况下,它一直说数量栏是含糊不清的,有人能帮忙吗?

SELECT SUM(AmountPaid),SUM(Quantity), ice_cream.IceCream
FROM ice_cream 
INNER JOIN ice_cream_ingredient ON (ice_cream.IceCreamID =
ice_cream_ingredient.fkIceCreamID)
INNER JOIN ingredients ON (ice_cream_ingredient.fkIngredientID =
ingredients.IngredientID)
INNER JOIN sales ON (sales.fkIceCreamID =
ice_cream.IceCreamID)
WHERE IceCream='Vanilla Dream'
qhhrdooz

qhhrdooz1#

当查询中有多个表时,应该始终限定列名。另外,学习使用表别名。
不清楚什么是正确的限定名。这里有一个猜测:

SELECT SUM(s.AmountPaid), SUM(s.Quantity), ic.IceCream
FROM ice_cream ic INNER JOIN
     ice_cream_ingredient ici
     ON ic.IceCreamID = ici.fkIceCreamID INNER JOIN
     ingredients i
     ON ici.fkIngredientID = i.IngredientID INNER JOIN
     sales s
     ON s.fkIceCreamID = ic.IceCreamID
WHERE ic.IceCream = 'Vanilla Dream';

相关问题