27,579
社区成员
发帖
与我相关
我的任务
分享
create table table_1(
goodsid varchar(20),
a varchar(10),
b varchar(10),
c varchar(10)
)
create table table_2(
goodsid varchar(20),
a varchar(10),
f varchar(10),
g varchar(10)
)
insert into table_1 values('dj001','a','b','c')
insert into table_1 values('dj001','a1','b1','c1')
insert into table_1 values('dj001','a2','b2','c2')
insert into table_2 values('dj001',null,'b','c')
insert into table_2 values('dj001','a',null,'c')
select * from table_1 a left join table_2 b on a.goodsid=b.goodsid
select * from table_1 a inner join table_2 b on a.goodsid=b.goodsid
select * from table_1 a full join table_2 b on a.goodsid=b.goodsid
select * from table_1 a right join table_2 b on a.goodsid=b.goodsid
--仔细看看这几个连接结果是一样的
select *
from table_1 t1 FULL OUTER JOIN
table_2 t2 ON t1.goodsid=t2.goodsid
select * from table_1
union
select * from table_2
2.
select * from table_1 a full join table_2 b on a.goodsid =b.goodsid