求一sql语句

blue_snow 2003-10-21 10:12:29
我想把一个表的三个字段a,b,c加为主键,但是里面有重复数据(即三个字段的值都一样)我怎么查出那些记录来呢?
...全文
33 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
xcloudky 2003-10-24
  • 打赏
  • 举报
回复
去网上找!
yonghengdizhen 2003-10-24
  • 打赏
  • 举报
回复
to blue_snow(因为所以)
存在性判断你管它输出什么干吗?
blue_snow 2003-10-24
  • 打赏
  • 举报
回复
我想问一下:select * from 表 tem where exists(
Select 1 from 表 group by a,b,c having count(*) > 1 and a=tem.a and b=tem.b and c=tem.c)中,select 1 是什么意思,有些看不懂
yonghengdizhen 2003-10-23
  • 打赏
  • 举报
回复
Select * from tablename ta where (select count(*) from tablename where a=ta.a and b.ta.b and c=ta.c)>1
xjwxiong 2003-10-23
  • 打赏
  • 举报
回复
select a,b,c,sum(d) as d from (select a,b,c,1 as d from table1)A
where d>1
group by a,b,c
guangli_zhang 2003-10-22
  • 打赏
  • 举报
回复
对不起,写错了
select * from table1 aa where (select count(*) from table1 bb where bb.a = aa.a and bb.b = aa.b and bb.c = aa.c) >= 2
guangli_zhang 2003-10-22
  • 打赏
  • 举报
回复
select * from table1 aa where (select count(*) from table1 bb where b.aa = a.aa and b.bb = a.bb and b.cc = a.cc) >= 2
银狐被占用 2003-10-21
  • 打赏
  • 举报
回复
select a,b,c from 表 group by a,b,c having count(*)>1
pengdali 2003-10-21
  • 打赏
  • 举报
回复
Select * from 表 where a=b and a=c


??
blue_snow 2003-10-21
  • 打赏
  • 举报
回复
to 大力
你的语句效果是一样的,我只想查出那些三个字段都一样的记录
lijinqiang 2003-10-21
  • 打赏
  • 举报
回复
pengdali(大力 V3.0)能达到效果
welyngj 2003-10-21
  • 打赏
  • 举报
回复
select * from tbl a where exists ( select a,b,c from tbl b where a.a=b.a
and a.b=b.b and a.c=b.c group by a,b,c having count(a)>1 )
blue_snow 2003-10-21
  • 打赏
  • 举报
回复
to 马可
按照你的方法还是查不出有哪些记录是重复的呀
pengdali 2003-10-21
  • 打赏
  • 举报
回复
select * from 表 tem where exists(
Select 1 from 表 group by a,b,c having count(*) > 1 and a=tem.a and b=tem.b and c=tem.c)
txlicenhe 2003-10-21
  • 打赏
  • 举报
回复
Select a,b,c from 表 group by a,b,c having count(*) > 1
lynx1111 2003-10-21
  • 打赏
  • 举报
回复
都是对的,楼主自己好好测一下
qdubit 2003-10-21
  • 打赏
  • 举报
回复
select a,b,c from 表 group by a,b,c having count(*)>1

22,207

社区成员

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

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