Oracle 外连接(outer join)

外连接(outer join):left join、right join、full join

        left join(左边的表不加限制):以左边的表作为基表,基表内容全部显示,再加上两张表匹配的内容。如果基表的内容在另一张表没有记录,则显示null

                select* from test a left join test2 b on a.id=b.id;

        right join(右边的表不加限制):以右边的表作为基表,基表内容全部显示,再加上两张表匹配的内容。如果基表的内容在另一张表没有记录,则显示null

        full join(两边的表都不限制)

创建两张表:

create table test(
  id  umber(10) not null,
  name  archar2(20),
  sex  archar2 (8),
  email  archar2 (20)
)
create table test2(
  id   number(10) not null,
  name varchar2(20),
  tel  varchar2 (11)
)
left join:

select * from test a left join test2 b on a.id=b.id;

right join:

select * from test a right join test2 b on a.id=b.id;

full join:

select * from test a full join test2 b on a.id=b.id;

select * from test2 a full join test b on a.id=b.id;




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值