同一个表中,如何写SQL语句查找某一字段重复的记录?
如下表,,A、B、C三个字段,ABC10SP20TP30RQ40WL50YQ我想找出的结果是:10、20、30和50...
如下表,,A、B、C三个字段,
A B C
10 S P
20 T P
30 R Q
40 W L
50 Y Q
我想找出的结果是:10、20、30和50 展开
A B C
10 S P
20 T P
30 R Q
40 W L
50 Y Q
我想找出的结果是:10、20、30和50 展开
展开全部
查询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 )
如果是小表可以这样写:
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 )
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT * FROM tab WHERE C in (
SELECT C
FROM tab
GROUP BY C
HAVING COUNT(A) > 1 )
SELECT C
FROM tab
GROUP BY C
HAVING COUNT(A) > 1 )
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select A from 表
group by A
having count(C)>=2
group by A
having count(C)>=2
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select A FROM 表
where C in (
SELECT C FROM 表
group by C
having count(C)>1)
where C in (
SELECT C FROM 表
group by C
having count(C)>1)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询