代码:
// 在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