加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle关联查询_join或(+)

发布时间:2020-12-12 15:03:37 所属栏目:百科 来源:网络整理
导读:场景1:从两个或多个表中取得数据。 select * from table1 a,table2 b where a.id=b.id (此种写法的可读性不好,关联条件和语句的过滤条件写在一块不便于阅读) select * from table1 a join table2 b using (id); (表之间的连接条件与表记录的筛选条件分开,
对等联接(关联上才显示) join a.id=b.id 左关联(左表为主表) left join a.id=b.id(+) 右关联(右表主表) right join a.id(+)=b.id 全关联(都显示) full join

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

场景1:从两个或多个表中取得数据。

select * from table1 a,table2 b where a.id=b.id (此种写法的可读性不好,关联条件和语句的过滤条件写在一块不便于阅读)

select * from table1 a join table2 b using (id); (表之间的连接条件与表记录的筛选条件分开,可读性较好)

场景2:表1不管能不能关联上表2(不管部门是否招到人),将表1都显示出来(将部门都显示出来)。

select * from emp a right join dept b using (deptno);

归纳: left,right 是指示主表的位置。(+)号则放在附属表后面。

    推荐文章
      热点阅读