删除pop_code重复的记录
DELETE FROM delivery_plan_product WHERE pop_code in
(SELECT pop_code FROM delivery_plan_product GROUP BY pop_code HAVING COUNT(pop_code) > 1)
and delivery_plan_product_id not in
(SELECT min(delivery_plan_product_id) FROM delivery_plan_product GROUP BY pop_code HAVING COUNT(pop_code)>1)
DELETE FROM delivery_plan_product WHERE pop_code in
(SELECT pop_code FROM delivery_plan_product GROUP BY pop_code HAVING COUNT(pop_code) > 1)
and delivery_plan_product_id not in
(SELECT min(delivery_plan_product_id) FROM delivery_plan_product GROUP BY pop_code HAVING COUNT(pop_code)>1)
本文提供了一种SQL解决方案,用于从数据库表“delivery_plan_product”中删除具有重复pop_code的记录,只保留每个pop_code对应的最小delivery_plan_product_id的记录。

被折叠的 条评论
为什么被折叠?



