我们可以用左右连接的联合替换完全连接吗?如果不是,为什么?
答案 0 :(得分:4)
'是',否则答案为“否”。
create table t1 (i int);
create table t2 (i int);
insert into t1 values (1);
insert into t1 values (2);
insert into t1 values (2);
insert into t2 values (3);
select * from t1 full join t2 on t1.i=t2.i
order by 1,2
1 (null)
2 2
2 2
(null) 3
select * from t1 left join t2 on t1.i=t2.i
union
select * from t1 right join t2 on t1.i=t2.i
order by 1,2
1 (null)
2 2
(null) 3
select * from t1 left join t2 on t1.i=t2.i
union all
select * from t1 right join t2 on t1.i=t2.i
order by 1,2
1 (null)
2 2
2 2
2 2
2 2
(null) 3