Mysql删除重复的数据 Mysql数据去重复_mysql数据库教程-查字典教程网
Mysql删除重复的数据 Mysql数据去重复
Mysql删除重复的数据 Mysql数据去重复
发布时间:2016-12-29 来源:查字典编辑
摘要:MySQL数据库中查询重复数据select*fromemployeegroupbyemp_namehavingcount(*)>1;Mysq...

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数据库学习
    热门mysql数据库学习
    编程开发子分类