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

soゝso 2016-08-22 14:56:39 1291

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

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

本文主题:

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

相关文章
OracleMysql删除重复数据OracleMysql数据重复
MySQL数据库表怎么锁定
MySql数据库优化注意的四个细节(方法)
Elasticsearch教程(八) elasticsearch delete 删除数据(Java)
MySQL数据库存储过程字符集问题,乱码的解决办法
MySQL数据库为用户设置密码,Mysql修改密码。Mysql忘记密码解决方法
Javascript 删除节点后是否需要将手动将事件解绑?
MySQL 分区、分表
Httpclent 请求限制,判断返回类型返回数据大小
JSOUP 教程,JSOUP请求JSON ,JSOUP返回JSON 数据
最新文章
MyEclipse8.5,MyEclipse10,安装ERMaster 建模插件 836
Redis与Memcached的比较 ,然后选择了Redis 2597
Redis 单线程模型分析 2247
Java Redis线程池ShardedJedisPool 使用方法,Java Jedis连接池的使用 8726
最热文章
Java Redis线程池ShardedJedisPool 使用方法,Java Jedis连接池的使用 8726
Redis与Memcached的比较 ,然后选择了Redis 2597
Redis 单线程模型分析 2247
MyEclipse8.5,MyEclipse10,安装ERMaster 建模插件 836

骚码加入我们 / 千人QQ群:259217951

入群需要5元,如果没有QQ钱包,可以先Alipay、微信,赞助然后加群主拉进。

二维码生成 来自 >> 二维码生成器

支付扫码

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

正在加载... ...