mysql 去除表中重复的数据,保留id最小的数据信息

-- 笨重方法
delete from 
	tb_person 
WHERE
	id NOT IN (  select id from (SELECT min(id) id FROM tb_person GROUP BY email  having count(1) > 1)  tm)
	and email in ( select email from ( SELECT email FROM tb_person GROUP BY email  having count(1) > 1)tm)
-- 获取最小id,排除id信息进行删除 DELETE from Person Where Id not in ( Select MIN(Id) as Id From Person Group by Email )

  

posted on 2020-06-01 11:05  零度千里  阅读(379)  评论(0编辑  收藏  举报

导航