私人领地

mysql 子查询sum失效

 

代码:

// 在mysql5.6,运行正常,5.7报错
SELECT sum((
select a.num where a.status =1) ) as total FROM mes_order_product AS a LEFT JOIN mes_order AS b ON a.osn = b.osn

 

修改后的代码,增加了表明limit

// 5.6 和5.7运行都正常
SELECT sum((
select a.num from mes_order_product where a.status =1 limit 0,1)) as total FROM mes_order_product AS a LEFT JOIN mes_order AS b ON a.osn = b.osn

 

posted @ 2021-07-26 19:43  狂奔的蜗牛Snails  阅读(218)  评论(0编辑  收藏  举报