mysql5.7 ORDER BY clause is not in GROUP BY clause and contains nonaggregated column

好郁闷,这句sql看着很正常,可是他就是报错,百度查资料基本都是修mysql的配置文件

SELECT item_id 
from tb_order_item as aa,tb_order as bb 
WHERE aa.order_id = bb.order_id 
GROUP BY aa.item_id 
ORDER BY bb.create_time desc 

解决方法

SELECT item_id 
from tb_order_item as aa,tb_order as bb 
WHERE aa.order_id = bb.order_id 
GROUP BY aa.item_id 
ORDER BY MAX(bb.create_time) desc 

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区