高分求一句SQL 急!!!

ballatong 2006-09-01 03:03:49
table1

custom AV quantity
AA 10 500
BB 100 100
DD 10 200
FF 20 20

table2

custom AV quantity
AA 20 1000
EE 10 100
DD 10 200
CC 20 200


要求得到如下结果

custom AV quantity custom AV quantity
AA 10 500 AA 20 1000
BB 100 100 null null null
DD 10 200 DD 10 200
FF 20 20 null null null
null null null CC 20 200

...全文
197 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jaway 2006-09-01
  • 打赏
  • 举报
回复
full join
thesameageaschina 2006-09-01
  • 打赏
  • 举报
回复
好象已经解决了。


我刚试着答题。 欢迎各位斧正。
you_99 2006-09-01
  • 打赏
  • 举报
回复
YiZhiNet(温馨提示------开帖请结帖)
你太职业了
you_99 2006-09-01
  • 打赏
  • 举报
回复
select * from table1 a full outer join table2 b on a.custom=b.custom

这个是正解
九斤半 2006-09-01
  • 打赏
  • 举报
回复
libin_ftsafe(子陌红尘:当libin告别ftsafe)留点分给我们啊~~~

create table table1(custom char(2),AV int,quantity int)
insert table1
select 'AA', 10 ,500 union all
select 'BB', 100 ,100 union all
select 'DD', 10 ,200 union all
select 'FF', 20 ,20
--select * from table1

create table table2(custom char(2),AV int,quantity int)
insert table2
select 'AA', 20 ,1000 union all
select 'EE', 10 ,100 union all
select 'DD', 10 ,200 union all
select 'CC', 20 ,200
--select * from table2

select A.*,B.*
from table1 A full join table2 B on A.custom=B.custom

drop table table1,table2
ballatong 2006-09-01
  • 打赏
  • 举报
回复
哦 是我遗漏了
子陌红尘 2006-09-01
  • 打赏
  • 举报
回复
table2.custom = 'EE' 的记录怎么被筛选掉了?还是楼主列出的结果中遗漏?
子陌红尘 2006-09-01
  • 打赏
  • 举报
回复
select * from table1 a full outer join table2 b on a.custom=b.custom

34,590

社区成员

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

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