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

Mysql 我见过很多模棱两可的问题,尝试过很多东西,但仍然不起作用,mysql,sql,ambiguous,Mysql,Sql,Ambiguous,我想知道,为什么在这种情况下,它一直说数量列是不明确的,有人能帮忙吗 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.

我想知道,为什么在这种情况下,它一直说数量列是不明确的,有人能帮忙吗

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'
当查询中有多个表时,应始终限定列名。此外,学习使用表别名

不清楚什么是正确的限定名。这里有一个猜测:

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';

列数量是否存在于您从中选择的多个表中?如果是这样,那么它不知道从哪个表中选择求和。这就是暧昧的意思。要修复此问题,请在列名之前添加表限定符。例如,
sales.Quantity