如何查询出A表中不存在于B中的记录

abitoom 2005-06-11 02:42:37
假设:
A表: B表:
A1字段 A2字段 B1字段 B2字段
1 11 1 55
2 22 4 66
3 33 7 999

如何查询出A表中不存在于B中的记录,也就是记录
2 22
3 33

但是,不能与B表组合,我只需要A表的记录,不需要B表的东西。
...全文
231 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xojxau 2005-06-14
  • 打赏
  • 举报
回复
select * from A where a.a1||a.a2 not in(select b.b1||b.b2 from b)
hanxingwuqing 2005-06-13
  • 打赏
  • 举报
回复
select * from A where A1 where not exists (select B1 from B where A1=B1)
heyixiang 2005-06-11
  • 打赏
  • 举报
回复
如果表的数据量大的话就不要用not in

用not exists 和 outer join where b.bi is null
bluecocoqd 2005-06-11
  • 打赏
  • 举报
回复
select * from A where A1 not in (select B1 from B where B1 is not null)

select * from A where A1 where not exists (select 1 from B where A1=B1)

select * from A
where A1 in (select A1 from A minus select B1 from B)

用minus、not in、not exists都可以实现
hsj20041004 2005-06-11
  • 打赏
  • 举报
回复
select * from A
where A1 not in ( select B1 from B)
kuaile14 2005-06-11
  • 打赏
  • 举报
回复
select * from A
where A1 in (select A1 from A minus select B1 from B)

17,089

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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