^
Mysql删除重复的数据 Mysql数据去重复
2016年12月25日
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);
相关阅读
详解MySQL用事件调度器Event Scheduler创建定时任务
MySQL rand函数实现随机数的方法
-
MySQL数据库优化技术之配置技巧总结
-
Linux上通过binlog文件恢复mysql数据库详细步骤
-
Mysql5.7.11在windows10上的安装与配置(解压版)
-
MySQL中实现插入或更新操作(类似Oracle的merge语句)
-
MySQL与Mongo简单的查询实例代码
-
MySql 5.7.14 解压版安装步骤详解
-
MySQL中interactive_timeout和wait_timeout的区别
-
Centos 6.5 下安装mysql 5.6.21的方法
-
MySQL外键使用及说明详解
-
Mysql 下中文乱码的问题解决方法总结