作者:粉红色头发丫头_960 | 来源:互联网 | 2024-09-30 14:13
代码:在mysql5.6,运行正常,5.7报错SELECTsum((selecta.numwherea.status1))astotalFROMmes_order_productA
代码:
// 在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