sqlÓï¾äÔõô°Ñ
a񡜧
100 Сºì 12
102 СÃ÷ 15
b񡜧
100 Сºì 13
103 С°× 23
±ä³É
100 Сºì 12 13
102 СÃ÷ 15 null
103 С°× null 23
ÄØ£¿£¿
full join
SQL code:
full join
SQL code:
select isnull(a.col1,b.col1),isnull(a.col2,b.col2),
a.col3,b.col3
from tb1 as a
full join tb2 as b
on a.col1=b.col1 and a.col2=b.col2
SQL code:
select isnull(a.col1,b.col1)col1,
isnull(a.col2,b.col2)col2,
a.col3 col3,
b.col3 col4
from ta a full join tb b
on a.col1=b.col1
SQL code:
if object_id('[ta]') is not null drop table [ta]
go
create table [ta] (col1 int,col2 nvarchar(4),col3 int)
insert into [ta]
select 100,N'Сºì',12 union all
select 102,N'СÃ÷',15
if object_id('[tb]') is not null drop table [tb]
go
create table [tb] (col1 nvarchar(6),col2 nvarchar(4),col3 int)
insert into [tb]
select '100',N'Сºì',13 union all
select '103',N'С°×',23
select isnull(a.