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 )