mysql - sql 分组查询问题。。
迷茫
迷茫 2017-04-17 15:07:04
0
2
651

表1

表2

查询语句和结果

结果只显示3条数据,我要显示product表的所有数据,怎么回事?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
Peter_Zhu

Please write like this, the reason for this is improper use of group by
select p.id,p.productname,p.productcode,p.price,l.num from p
left join (select pid, sum(num) as num from wlms_stock group by pid) l on p.id = l.pid

迷茫

group by should be placed after line 29

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template