//获取相同用户名的数据 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)