MySql 根据多个字段删除重复的数据

DELETE FROM 表名 WHERE (字段1,字段2,字段3)
IN
(SELECT 字段1,字段2,字段3 FROM (SELECT 字段1,字段2,字段3 FROM 表名 GROUP BY 字段1,字段2,字段3 HAVING COUNT()>1) s1)
AND
id NOT IN (SELECT id FROM (SELECT id FROM 表名 GROUP BY 字段1,字段2,字段3 HAVING COUNT(
)>1) s2);

(非原创–防止下次要用找不到)
来源地址 :https://www.cnblogs.com/XiaoMingBlingBling/p/11146375.html

你可能感兴趣的:(MYSQL,mysql)