删除mysql中的重复数据

--创建临时表tmp,保存id最小的值

create table tmp as select min(id) as col1 from student group by name;


--删除不在临时表中的数据(重复数据)

delete from student where id not in (select col1 from tmp); 


--删除临时表
drop table tmp;

猜你喜欢

转载自blog.csdn.net/frinder/article/details/11964005