SQL命令错误

时间:2015-02-10 07:12:33

标签: mysql select

我是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

3 个答案:

答案 0 :(得分:0)

我看到你从两个表mm和bomz FROM mm,bomz中取记录,并且在你的陈述中没有这个的连接条款。

答案 1 :(得分:0)

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

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;

答案 2 :(得分:0)

您需要一个JOIN或WHERE子句来将表链接在一起