需求
由于某些原因,数据库表中出现了一下重复数据
查询重复数据
1
| select * from member where mobile in (select mobile from member group by mobile having count(*)>1);
|
删除其他重复记录保留最新一条
1
| delete from member where id not in (select t.max_id from (select max(id) as max_id from member group by mobile having count(*)>1) as t);
|