日期:2014-05-17 浏览次数:20495 次
if object_id('[TBA]') is not null drop table [TBA]
go
create table [TBA] (id int,name nvarchar(2))
insert into [TBA]
select 1,'A' union all
select 2,'B' union all
select 3,'C'
if object_id('[TBB]') is not null drop table [TBB]
go
create table [TBB] (id int,test nvarchar(2))
insert into [TBB]
select 2,'A' union all
select 4,'B'
select * from [TBA]
select * from [TBB]
SELECT ISNULL(TBA.id,TBB.id) AS id,NAME,test
FROM dbo.TBA
FULL JOIN TBB ON TBA.id = TBB.id
/*
id NAME test
1 A NULL
2 B A
3 C NULL
4 NULL B*/