45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:如何删除Mysql中重复数据?

如何删除Mysql中重复数据?

2016-09-09 16:06:58 来源:www.45fan.com 【

如何删除Mysql中重复数据?

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);


本文地址:http://www.45fan.com/a/question/74091.html
Tags: mysql 数据 重复
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部