mysql 查询某个字段有重复记录,并显示出具体的记录信息

时间:2022-12-08 15:08:42

1、 查询某个字段有重复记录的记录

如:查询设备表terminal中phone字段有重复记录的sql

select phone  from terminal group by phone having count(0)>1;

2、显示出重复信息的记录

select * from terminal where phone in( select phone from terminal where 1  group by phone having count(0)>1);