SQL求教

二当家 2008-09-23 10:37:06
一张表A 有个列名是name
还有个列名是id
找出id重复的数据
...全文
59 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
nalnait 2008-09-23
  • 打赏
  • 举报
回复
mark...
zjw2004112 2008-09-23
  • 打赏
  • 举报
回复
select * from a where id in
(select id from a group by id having count(*)>1)
xabcxyz 2008-09-23
  • 打赏
  • 举报
回复
楼上快速啊,再来一个笨办法的:

select * from tb
where id in (
select id from (
select id, count(*) as cnt from tb group by id
) where cnt>1
)
order by id
anovice 2008-09-23
  • 打赏
  • 举报
回复

select * from a where id in
(select id from a group by id having count(*)>1)
等不到来世 2008-09-23
  • 打赏
  • 举报
回复

select * from tb a
where (select count(id) from tb where id=a.id)>1
dawugui 2008-09-23
  • 打赏
  • 举报
回复
[Quote=引用楼主 keinshen 的帖子:]
一张表A 有个列名是name
还有个列名是id
找出id重复的数据
[/Quote]
select * from tb where id in (select id from tb group by id having count(id) > 1)
zoujp_xyz 2008-09-23
  • 打赏
  • 举报
回复
select ...
from tb group by id having Count(*)>1

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧