gpt4 book ai didi

mysql - SQL命令错误

转载 作者:行者123 更新时间:2023-11-29 23:02:29 26 4
gpt4 key购买 nike

我是 SQL 新手,有人可以回答我有什么问题吗?!谢谢。

SELECT  
bom.Parent_Material_Number,
mm.Material_Number,
mm.Material_Descr_HU,
bom.Child_Material_Number
FROM mm,bom
GROUP BY mm.Material_Descr_HU

最佳答案

您的查询有误。如果您打算使用 GROUP BY 子句,请确保取消分组字段具有聚合,例如 SUM()、MIN()、MAX() 等。请参阅下面的示例:

SELECT  
MIN(bom.Parent_Material_Number),
MAX(mm.Material_Number),
mm.Material_Descr_HU,
MIN(bom.Child_Material_Number)
FROM mm,bom
WHERE bom.Parent_Material_Number = mm.Material_Number
GROUP BY mm.Material_Descr_HU;

您还可以显式联接。见下文:

    SELECT  
MIN(bom.Parent_Material_Number),
MAX(mm.Material_Number),
mm.Material_Descr_HU,
MIN(bom.Child_Material_Number)
FROM mm INNER JOIN bom
ON bom.Parent_Material_Number = mm.Material_Number
GROUP BY mm.Material_Descr_HU;

关于mysql - SQL命令错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28426013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com