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); (表之间的连接条件与表记录的筛选条件分开,
场景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 是指示主表的位置。(+)号则放在附属表后面。 |