Mysql 删除表重复记录,当有多条重复记录时,保存最新记录。
方法一、
delete from IP where ip_id in (select * from (select max(ip_id) as ip_id from IP group by ip_name having count(ip_id)>1) as a)
方法二、
delete IP as a from IP as a, (SELECT ip_name,min(ip_id) as ip_id from IP GROUP BY ip_name having count(ip_name)>1) as b where a.ip_name = b.ip_name and a.ip_id= b.ip_id
转载于:https://www.cnblogs.com/yixiong/archive/2012/07/18/2597390.html
相关资源:MySQL删除重复记录