同一个表中,如何写SQL语句查找某一字段重复的记录?
同一个表中,如何写SQL语句查找某一字段重复的记录?
日期:2011-04-02 10:15:21 人气:1
查询C字段有重复的记录吗?
如果是小表可以这样写:
select a from tabname
where c in
(select c from tabname group by c having count(1) >1 )
大表(需建c列索引):
select a from tabname a
where exists (select c from tabname b where b.c=a.c group by c having count(1) >1 )