在不动表结构的情况下还能优化该SQL吗(效率太低了)
SELECT DISTINCT
GROUP_CONCAT(
DISTINCT pch.erpContractNumber
) AS fbk22,
poh.*, IFNULL(eei.shortName, eei.fullName) AS companyShortName,
GROUP_CONCAT(DISTINCT poi.fbk7) AS materialNumber
FROM
purchase_order_header poh
LEFT JOIN purchase_order_item poi ON poh.purchaseOrderNumber = poi.purchaseOrderNumber
AND poh.elsAccount = poi.elsAccount
LEFT JOIN els_enterprise_info eei ON eei.elsAccount = poh.toElsAccount
LEFT JOIN purchase_contract_head pch ON pch.elsAccount = poh.elsAccount
AND poh.purchaseOrderNumber = pch.erpContractNumber
AND pch.fbk15 = '1'
WHERE
poh.elsAccount = '120000'
AND poh.orderStatus IN ("0","1","2","3","4","5","6","7")
AND poh.orderSendStatus IN ("0")
GROUP BY
poh.purchaseOrderNumber
ORDER BY
poh.logtime DESC,
poh.purchaseOrderNumber DESC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
联表查询尽量少用
in 也很吃资源 少用
不动表结构的话优化起来很困难啊