请帮忙写出SQL语句

prettyBoy2002 2003-08-20 10:51:05
有两个表他们结构一样,如A(nodekey,name,bz)和B(nodekey,name,bz)
A表中nodekey和name为主键,B表中也是nodekey和name为主键。
写出SQL语句,检索出同时满足条件(1)在B表中存在而在A表中不存在的记录集.(2)B表的bz>5。

我只知道满足条件(1)写法为:select * from B where not exists (select *
from A
where A.nodeky=B.nodeky and A.name=B.name)

...全文
38 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 2003-08-20
  • 打赏
  • 举报
回复
select * from B where not exists (select 1 from A where A.nodeky=B.nodeky and A.name=B.name) and bz>5
CrazyFor 2003-08-20
  • 打赏
  • 举报
回复
OR:

select b.* from B表 b left join A表 a on a.nodekey=b.nodekey and a.name=b.name
where a.nodekey is null and b.bz>5
waitwater 2003-08-20
  • 打赏
  • 举报
回复
select * from B where not exists (select * from A where A.nodeky=B.nodeky and A.name=B.name) and bz>5
amtyuranus 2003-08-20
  • 打赏
  • 举报
回复
哈哈,都一个吊样
amtyuranus 2003-08-20
  • 打赏
  • 举报
回复
select * from B where not exists (select * from A
where A.nodeky=B.nodeky and A.name=B.name) and bz>5
CrazyFor 2003-08-20
  • 打赏
  • 举报
回复
OR:

select b.* from B表 b left join A表 a on a.nodekey=b.nodekey and a.name=b.name
where a.nodekey is null and b.bz>5
pengdali 2003-08-20
  • 打赏
  • 举报
回复
select * from B where not exists (select * from A where A.nodeky=B.nodeky and A.name=B.name) and bz>5
CrazyFor 2003-08-20
  • 打赏
  • 举报
回复
select * from B where not exists (select *
from A
where A.nodeky=B.nodeky and A.name=B.name) and b.bz>5
dafu71 2003-08-20
  • 打赏
  • 举报
回复
select * from B where not exists (select * from A
where A.nodeky=B.nodeky and A.name=B.name) and bz>5

22,207

社区成员

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

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