新手查询问题啊,超级容易到手的分啊。谁答对了就给谁

v192 2005-04-14 04:46:39
如题
表A{a, b , c}
1 11 a
2 22 b
3 11 a
4 44 444
5 22 b
6 66 666

表A里的有些记录是用A.b和A.c联系的 他们相等
我要查出所有这样数据
最后要表A{a, b , c}
1 11 a
2 22 b
3 11 a
5 22 b
怎么做啊
...全文
159 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Well 2005-04-14
  • 打赏
  • 举报
回复

select * from 表A a
where exists(select * from 表A where b=a.b and c=a.c and a<>a.a)
rds521 2005-04-14
  • 打赏
  • 举报
回复
也就是我要修改一条记录的A.c,在同表里有另一条记录的A.c的直为x,这时我就要通过A.b和A.c关联过去查到另一条记录的A.c的直
再看撒!我的目的是这样的
paoluo 2005-04-14
  • 打赏
  • 举报
回复

那我理解错了

Select * from A T Where Exists(Select * from A Where a<>T.a And b=T.b And c=T.c)
xluzhong 2005-04-14
  • 打赏
  • 举报
回复
select *
from 表A a
where exists(select 1 from 表A where b=a.b and c=a.c and a<>a.a)
chd2001 2005-04-14
  • 打赏
  • 举报
回复
select * from a where (select count(b) from a group by b,c)>1
xluzhong 2005-04-14
  • 打赏
  • 举报
回复
select *
from 表A a
where exists(select 1 from 表A where b=a.b and c=a.c and id<>a.id)
chd2001 2005-04-14
  • 打赏
  • 举报
回复
select * from a where (select count(b) from a group by b,c)>2
zjcxc 元老 2005-04-14
  • 打赏
  • 举报
回复
select * from 表A a
where exists(select * from 表A where b=a.b and c=a.c and a<>a.a)
paoluo 2005-04-14
  • 打赏
  • 举报
回复

这样试试

Select * from A Where c Not Like '[a-Z]'
zjcxc 元老 2005-04-14
  • 打赏
  • 举报
回复
select * from 表A a
where exists(select * from 表A where b=a.b and c=a.c and a<>a.a)
hnhn 2005-04-14
  • 打赏
  • 举报
回复
select a.a,a.b,a.c from A a where (select count(*) from A b where a.b=b.b and a.c=b.c)>1

34,593

社区成员

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

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