java mysql删除表中多余的重复记录(多个字段),只留有id最小的记录
作者:互联网
mysql 删除表中多余的重复记录(多个字段),只留有id最小的记录
DELETE FROM 表1 f WHERE
(f.字段1,f.字段2) IN ( SELECT 字段1,字段2 FROM 表1 GROUP BY 字段1,字段2 HAVING count(*) > 1 )
AND id NOT IN ( SELECT min(id) FROM 表1 GROUP BY 字段1,字段2 HAVING count(*) > 1 )
标签:count,java,mysql,HAVING,字段,表中,id 来源: https://www.cnblogs.com/dawndefend/p/16652035.html