select * from table group by 关键字 having count(*) >1
select 列1,列2 from 表 group by 列1,列2 having count(*)>1
select * from 表 where 分组列 in ( select 分组列 from 表 group by 分组列 having count(*)>1)
select * from 表 where 分组列 in ( select 分组列 from 表 group by 分组列 having count(*)>1)其实这个最好。
select * from 表 where 分组列1,分组列2 in ( select 分组列1,分组列2 from 表 group by 分组列1,分组列3 having count(*)>1)不能成功。
写错,呵呵。select * from 表 where 分组列1,分组列2 in ( select 分组列1,分组列2 from 表 group by 分组列1,分组列2 having count(*)>1)不能成功。
select 列1,列2,..... from 表 group by 列1,列2,.... having count(*)>1 select * from 表 aa where exists ( select count(*) from 表 bb where aa.分组列1=bb.分组列1 and aa.分组列2=bb.分组列2 and ....)>1
查找某字段值重复记录 select * from table1 a, table1 b where a.A<> b.A and a.C=b.C 其中A为主键,C为要查找重复的字段例如下表:tablename P_code C_code nameselect * from tablename a tablename b where a.P_code<>b.P_code and a. C_code<>b.C_code and a.name=b.name
select 分组列 from 表 group by 分组列 having count(*)>1)
select 分组列 from 表 group by 分组列 having count(*)>1)其实这个最好。
select 分组列1,分组列2 from 表 group by 分组列1,分组列3 having count(*)>1)不能成功。
select 分组列1,分组列2 from 表 group by 分组列1,分组列2 having count(*)>1)不能成功。
select * from 表 aa where exists (
select count(*) from 表 bb where aa.分组列1=bb.分组列1 and aa.分组列2=bb.分组列2 and ....)>1
select * from table1 a, table1 b
where a.A<> b.A and a.C=b.C
其中A为主键,C为要查找重复的字段例如下表:tablename
P_code C_code nameselect * from tablename a tablename b
where a.P_code<>b.P_code and a. C_code<>b.C_code and a.name=b.name