合并两个表的问题(50分)

  • 主题发起人 主题发起人 supperwing
  • 开始时间 开始时间
S

supperwing

Unregistered / Unconfirmed
GUEST, unregistred user!
表1
款号,下单数
AAAA 1230
表2
款号,完成数
AAAA 1000
请问如何生成 表3
款号,下单数,完成数
AAAA 1230 1000
 
select * 表1 left join select 完成数 from 表面2 where 表1.款号=表2.款号

可能有点语法错误自已调一下..
 
谢谢你!
试过了,不行啊
 
select 款号,下单数,完成数 from 表1,表2 where 表1.款号=表2.款号
 
多表查询

select 表1.款号,表1.下单数,表2.完成数 from 表1,表2 where 表1.款号=表2.款号




select 表1.款号,表1.下单数,表2.完成数 into 表3 from 表1,表2 where 表1.款号=表2.款号
 
or

select a.款号,a.下单数,b.完成数 from 表1 a join 表2 b on a.款号=b.款号
 
select 表1.款号,表1.下单数,表2.完成数 from 表1,表2
where 表1.款号=表2.款号
 
select 款号,下单数,完成数 into 表3 from 表1,表2 where 表1.款号=表2.款号
 
select a.款号,sum(isnull(a.下单数,0)) as 下单数,sum(isnull(b.完成数,0)) as 完成数 from 表1 a left join 表2 b on a.款号=b.款号 group by a.款号
 
联表操作,然后select 需要的 字段 就可以了 ~~~

select a.*,b.column from a left join b on ..........
 
后退
顶部