急急急急急!高手帮忙啊!

kirinboy 2004-12-23 04:34:18
在一个表中,有若干记录的某个字段重复,现在只想把这些重复的记录取出来
应该如何操作?

急急急急急!!!!!
...全文
83 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
kirinboy 2004-12-24
  • 打赏
  • 举报
回复
谢谢各位,已经搞定了,用的是exist
playyuer 2004-12-23
  • 打赏
  • 举报
回复
select *
from T a
where (select count(*) from T where 某个重复字段 = a.某个重复字段) > 1
didoleo 2004-12-23
  • 打赏
  • 举报
回复
或者
select * from 表 a
where exists (select 1 from 表 where 某个重复字段=a.某个重复字段
group by 某个重复字段 having count(某个重复字段)>1)
didoleo 2004-12-23
  • 打赏
  • 举报
回复
select * from 表 a join
(select 某个重复字段,count(某个重复字段) as idd from 表
group by 某个重复字段 having count(某个重复字段)>1
) b
on a.某个重复字段=b.某个重复字段
NinGoo 2004-12-23
  • 打赏
  • 举报
回复

select * from table1 a where id in (select id from table1 id=a.id and other<>a.other)

楼主的意思是要所有重复得记录吧,上面的other为你的一个并不重复的其他字段
kirinboy 2004-12-23
  • 打赏
  • 举报
回复
不是,是把所有的记录都取出来,包括重复的,因为这些记录的其他字段并不重复
NinGoo 2004-12-23
  • 打赏
  • 举报
回复
id为你想查的字段
LBYYBL 2004-12-23
  • 打赏
  • 举报
回复
select 字段名 from t group by 字段名 having count(1)>1
NinGoo 2004-12-23
  • 打赏
  • 举报
回复
select * from table1 where id in (select id from table1 group by id having count(*) > 1)

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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