SELECT c.cust_id,c.cust_name,o.order_num,o.order_date,o.cust_id,count(*)
from customers c LEFT JOIN orders o
on c.cust_id=o.cust_id
GROUP BY c.cust_id;
本机:windows10,navicat15,mysql8.0.22
在执行上述语句查询时,因为加了另一个表的字段:o.order_num,o.order_date,o.cust_id,运行就报错,如下:
Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated c