Mysql删除表重复记录
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