• 全部
  • 基础类
  • 应用实例
  • 新技术前沿

向大家求一条sql语句,谢谢各位 xdjm了

bigworld99 2006-01-21 11:21:51
有三个表 yonghu(number,money1)
addition(number,money2)
addition(number,money3)
查询的结果要变为(number,money1,money2,money3)
谢谢大家了,关键是不知道如何左连接,以及如何很好的先取出三表中的所有number
...全文
50 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zhangyang555 2006-01-21
select A.*,B.money2,C.money3 from yonghu A inner join addition B on A.number=B.number
inner join addition C on A.number=C.number
回复
OracleRoob 2006-01-21

create table #yonghu(number int, money1 money)
create table #addition1(number int, money2 money)
create table #addition2(number int, money3 money)

insert into #yonghu (number,money1) values(1,1)
insert into #yonghu (number,money1) values(1,2)
insert into #yonghu (number,money1) values(6,3)
insert into #addition1 (number,money2) values(2,2)
insert into #addition2 (number,money3) values(3,3)


select T.number,T1.money1,T2.money2,T3.money3
from
(
select number
from #yonghu
union
select number
from #addition1
union
select number
from #addition2 ) T
left join #yonghu T1 on T.number=T1.number
left join #addition1 T2 on T.number=T2.number
left join #addition2 T3 on T.number=T3.number

drop table #yonghu,#addition1,#addition2
回复
liujx_1999 2006-01-21
select A.*,B.money2,C.money3 from yonghu A inner join addition B on A.number=B.number
inner join addition C on A.number=C.number
回复
samson_www 2006-01-21
select c.money3,d.money1,d.money2,colesec(c.number,d.number) as bumber from (select a.money1,b.money2,colesec(a.numeber,b.numeber) as number from a full outer join b on b.number=a.number) d full outer join c on c.number=d.number
回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2006-01-21 11:21
社区公告
暂无公告