看不出来通过什么来关联的 行号?select px=identity(int,1,1),* into #a from 表1 select px=identity(int,1,1),* into #b from 表2select a.id[表1id],a.货号,a.进货,b.id[表2ID],b.销售,b.金额 from #a a right join #b b on a.px=b.px
我用 select a.*,b.* from a left outer join b on a.id=b.id 连接的结果 表1ID 货号 进货 表2ID 销售 金额 --------------- 1 001 20 1 4 4 1 001 20 1 4 4 2 002 15 2 4 4
行号?select px=identity(int,1,1),* into #a from 表1
select px=identity(int,1,1),* into #b from 表2select a.id[表1id],a.货号,a.进货,b.id[表2ID],b.销售,b.金额 from #a a right join #b b
on a.px=b.px
---------------
1 001 20 1 4 4
1 001 20 1 4 4
2 002 15 2 4 4
结果显示表1有条记录是重复的,我怎样才能把这条记录换成
Null Null Null 1 4 4