SET SESSION group_concat_max_len = 102400;
SELECT GROUP_CONCAT(CONCAT("'",mo.id,"'")) order_id_str
FROM mall_order mo LEFT JOIN mall_order_goods mog ON mo.mongo_id=mog.order_id
WHERE mo.is_sub=1 AND mog.mongo_id is NULL
AND mo.order_sn IN(SELECT order_sn FROM mall_order WHERE is_sub=1 GROUP BY order_sn HAVING count(*)>1 ORDER BY id ASC)
ORDER BY mo.id ASC
DELETE FROM mall_order WHERE id IN(
order_id_str
)
转载于:https://blog.51cto.com/hehe1987/1762976