Mysql删除重复的数据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);

到此这篇关于Mysql删除重复的数据Mysql数据去重复就介绍到这了。若要梦想实现,先从梦中醒来。五月你好!更多相关Mysql删除重复的数据Mysql数据去重复内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

您可能有感兴趣的文章
centos7安装MySQL教程

MySQL常用SQL查询语句(含复杂SQL查询)

MySQL细数发生索引失效的情况

mysqlenum字段类型的谨慎如何使用

Mysql体系化探讨令人头疼的JOIN运算