`
frinder
  • 浏览: 36541 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

删除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;

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics