sql-获取重复和删除重复数据

//获取相同用户名的数据
select name,Count(name) from user group by name having Count(name) >1
//删除相同的数据,保留最大的id或者最小的id min(id)
delete from user where id not in(select max(id) from user group by name)

 

posted @ 2019-06-06 14:21  npe0  阅读(3738)  评论(0编辑  收藏  举报