标签:bsp rom sel 存在 class into 保留 art sele
业务场景:删除评论表中对同一订单同一商品的重复评论,只保留最早的一条。
SELECT order_id,product_id,COUNT(*) FROM product_comment GROUP BY order_id,product_id HAVING COUNT(*)>1;
CREATE TABLE bak_product_comment_18051801 LIKE product_comment;
INSERT INTO bak_product_comment_18051801 SELECT * FROM product_comment;
DELETE a FROM product_comment a JOIN( SELECT order_id,product_id,MIN(comment_id) AS comment_id FROM product_comment GROUP BY order_id,product_id HAVING COUNT(*)>=2 ) b ON a.order_id=b.order_id AND a.product_id=b.product_id AND a.comment_id>b.comment_id
标签:bsp rom sel 存在 class into 保留 art sele
原文地址:https://www.cnblogs.com/yizhiamumu/p/9055119.html