日期:2014-05-17 浏览次数:20591 次
if object_id('[TBA]') is not null drop table [TBA]
go
create table [TBA] (学号 nvarchar(4),语文 int)
insert into [TBA]
select '01',20 union all
select '02',30 union all
select '03',40
if object_id('[TBB]') is not null drop table [TBB]
go
create table [TBB] (学号 nvarchar(4),数学 int)
insert into [TBB]
select '03',10 union all
select '04',50
select * from [TBA]
select * from [TBB]
SELECT ISNULL(tba.学号,tbb.学号) AS 学号,ISNULL(TBA.语文,0)AS 语文,ISNULL(TBB.数学,0)AS 数学
FROM dbo.TBA
full JOIN TBB ON tba.学号 = TBb.学号
/*
学号 语文 数学
01 20 0
02 30 0
03 40 10
04 0 50*/