mysql查询重复数据

发布于:2021-12-16 11:28:13

表全部数据

38b9c0cb01da7a1af8b274fbd0c38196.png

 -------------------

1 查询people_no重复的记录

select * from peoplewhere people_no in (select   people_no from   people group by   people_no having count(people_no) > 1);

----------------------

2 查询people_no重复的记录 ,排除最小id,如果删除改为delete from

select * from peoplewhere people_no in (select   people_no from people group by   people_no   having count(people_no) > 1) and  id not in (select min(id) from   people group by people_no having count(people_no)>1);

-----------------------------

3 查询people_no people_name重复的记录

select * from people awhere (a.people_no,a.people_name) in (select people_no,people_name from people GROUP BY people_no,people_name HAVING count(*)>1);

 

-----------------------------------

4 查询people_no people_name重复的记录,排除最小id

select * from people awhere (a.people_no,a.people_name) in (select people_no,people_name from people GROUP BY people_no,people_name HAVING count(*)>1) anda.id not in    (select min(id) from people GROUP BY people_no,people_name HAVING count(*)>1);

 

https://www.cnblogs.com/LDDXFS/p/9867928.html

阅读 426+

一片空白

父爱如山,不善表达。回想十多年前,总记得父亲有个宽厚的肩膀,小小的自己跨坐在上面,越过人山人海去看更广阔的天空,那个时候期望自己有一双翅膀,能够像鸟儿一样飞得高,看得远。虽然父亲有时会和自己开玩笑,但在做错事的时候会受到严厉的训斥。父亲有双粗糙的大手掌。