求个SQL 找重复信息的

来源:百度知道 编辑:UC知道 时间:2024/06/09 11:58:13
某个字段有重复的信息,我要把重复的信息找出来,就是这样。

SELECT <有重复的某列名> FROM <表名> GROUP BY <有重复的某列名> HAVING COUNT(*)>1;

select * from table1 where field1 in(
select field1 from table1 group by field1 having count(*)>1
)

select 字段名
from 表名
group by 字段名
having count(字段名)>=2
这是找出有重复记录的信息

select *
from 表名
where 字段名 in
(select 字段名
from 表名
group by 字段名
having count(字段名)>=2
)
这是找出重复的信息

select *
from 表名
where 字段 in (select 字段
from 表名
group by 字段
having count(字段) > 1)