新手求教:两张表查询

kingleap111 2009-04-03 04:59:31
有表A 字段a,b
表B 字段c,d
求一SQL找出A.a不存在与B.c中或A.b不存在B.d中
...全文
72 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lg3605119 2009-04-03
  • 打赏
  • 举报
回复

select * from a where not exists(select * from b where a.a=b.c and a.b=b.d)
htl258_Tony 2009-04-03
  • 打赏
  • 举报
回复
select a from 表A t where not exists(select 1 from 表B where t.a=c or t.b=d)
写错,改下.
Teng_s2000 2009-04-03
  • 打赏
  • 举报
回复
htl258_Tony 2009-04-03
  • 打赏
  • 举报
回复
select a from 表A t where not exists(select 1 from 表B where t.a=c or t.a=d)
yygyogfny 2009-04-03
  • 打赏
  • 举报
回复
select * from a aa where not exists(select 1 from b where c = aa.a or b = aa.b)
liangCK 2009-04-03
  • 打赏
  • 举报
回复
SELECT *
FROM A
WHERE NOT EXISTS(SELECT * FROM B WHERE A.a=B.c OR A.b=B.d)

34,575

社区成员

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

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