求个SQL语句如何写

xingjiaren 2007-02-02 09:00:59
A 、B两表
现在想检索出 A表中的x或者y字段内容 在B表中没有的数据

比如:
   A表          B表
x y x y
11 1 11 1
11 2 11 2
21 1 21 2

结果是需要把 A表的 21 1 这组数据检索出来。
不知道表达清楚没有,大家帮帮忙
...全文
284 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
sanmao136 2007-02-06
  • 打赏
  • 举报
回复
提供一个写法:
select A.* from A
where A.x + A.y not in (select B.x + B.y from B);
lakehubo 2007-02-06
  • 打赏
  • 举报
回复
如果是 oracle
select * from A
minus
select * from B
yuyu1980 2007-02-05
  • 打赏
  • 举报
回复
select * from a where not exists
(select 1 from b where a.x=b.x and a.y=b.y)
WOFEIYANG 2007-02-05
  • 打赏
  • 举报
回复
select a.x,a.y from a,b
where a.x <>b.x and a.y<>b.y
AFIC 2007-02-02
  • 打赏
  • 举报
回复
select * from a
where x||','||y not in
(select x||','||y from b)

数据中有逗号就换其他分隔符。
xingjiaren 2007-02-02
  • 打赏
  • 举报
回复
oracle
AFIC 2007-02-02
  • 打赏
  • 举报
回复
先说说啥数据库……
youqiong 2007-02-02
  • 打赏
  • 举报
回复
select * from a
where a.x not in( select distinct b.x from b )
or
a.y not in (select distinct b.y from b)

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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