`
zjnbshifox
  • 浏览: 312777 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

Mysql oracle删除重复记录的sql

sql 
阅读更多
MYSQL
drop TABLE if EXISTS tmp_t;
create TABLE tmp_t select min(id) id,`name`  from comp_info group by `name` having count(`name`)>1 ;
delete a.* from comp_info a,tmp_t b where b.`name`=a.`name` and a.id>b.id;
truncate table tmp_t;
drop TABLE if EXISTS tmp_t;


Oracle
delete from gqh_sch_info 
where sch_name  in (select  sch_name  from gqh_sch_info  group  by  sch_name   having  count(sch_name) > 1)
and rowid not in (select min(rowid) from  gqh_sch_info  group by sch_name  having count(sch_name)>1)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics