Oracle与Mysql删除重复的数据,Oracle和Mysql数据去重复

JSON 2016-08-22 14:56:39 5493

Oracle  数据库中查询重复数据:

select * from employee group by emp_name having count (*)>1;

Oracle  查询可以删除的重复数据

select t1.* from employee t1 where (t1.emp_name) in (SELECT t2.emp_name from employee t2 group by emp_name having count (*)>1) and t1.emp_id not in (select min(t3.emp_id) from employee t3 group by emp_name having count (*)>1);

Oracle 删除重复数据

delete from employee t1 where (t1.emp_name) in (SELECT t2.emp_name from employee t2 group by emp_name having count (*)>1) and t1.emp_id not in (select min(t3.emp_id) from employee t3 group by emp_name having count (*)>1);

MySQL数据库中查询重复数据

select * from employee group by emp_name having count (*)>1;

Mysql  查询可以删除的重复数据

select t1.* from employee t1 where (t1.emp_name) in (select t4.emp_name from (select t2.emp_name from employee t2 group by t2.emp_name having count(*)>1) t4) and t1.emp_id not in (select t5.emp_id from (select min(t3.emp_id) as emp_id from employee t3 group by t3.emp_name having count(*)>1) t5);

Mysql  删除重复的数据

delete t1 from employee t1 where (t1.emp_name) in (select t4.emp_name from (select t2.emp_name from employee t2 group by t2.emp_name having count(*)>1) t4) and t1.emp_id not in (select t5.emp_id from (select min(t3.emp_id) as emp_id from employee t3 group by t3.emp_name having count(*)>1) t5);


版权所属:SO JSON在线解析

原文地址:https://www.sojson.com/blog/155.html

转载时必须以链接形式注明原始出处及本声明。

本文主题:

如果本文对你有帮助,那么请你赞助我,让我更有激情的写下去,帮助更多的人。

关于作者
一个低调而闷骚的男人。
相关文章
Java 随机从 List 随机获取多个不重复对象,Mysql 随机10条数据
MySql数据库优化注意的四个细节(方法)
MySQL数据库表怎么锁定
Elasticsearch教程(八) elasticsearch delete 删除数据(Java)
MySQL数据库为用户设置密码,Mysql修改密码。Mysql忘记密码解决方法
MySQL数据库存储过程字符集问题,乱码的解决办法
使用七牛云存储实现图片API,自动删除图片方案合集
Javascript 删除节点后是否需要将手动将事件解绑?
MySQL 分区、分表
CDN + 数据中心粗粒度构想
最新文章
Java获取浏览器请求头(User-Agent),分析浏览器信息,系统信息的几种办法。 138208
最热文章
Java获取浏览器请求头(User-Agent),分析浏览器信息,系统信息的几种办法。 138208
支付扫码

所有赞助/开支都讲公开明细,用于网站维护:赞助名单查看

查看我的收藏

正在加载... ...