-
SQL语言基础中包含对外连接的使用
资源介绍
使用外连接
*
SQL> SELECT e.ename, d.deptno, d.dname
2 FROM emp e, dept d
3 WHERE e.deptno(+) = d.deptno
4 ORDER BY e.deptno;
ENAME DEPTNO DNAME
---------- --------- -------------
KING 10 ACCOUNTING
CLARK 10 ACCOUNTING
...
40 OPERATIONS
15 rows selected.
*
SELECT e.ename, d.deptno, d.dname
FROM emp e, dept d
WHERE e.deptno(+) = d.deptno
ORDER BY e.deptno;
Returning Records with No Direct Match with Outer Joins (continued)
The slide example displays numbers and names for all the departments. The OPERATIONS department, which does not have any employees, is also displayed.
Outer Join Restrictions
The outer join operator can appear on only one side of the expression—the side that has information missing. It returns those rows from one table that have no direct match in the other table.
A condition involving an outer join cannot use the IN operator or be linked to another condition by the OR operator.
全外连接:
SELECT e.ename, d.deptno, d.dname FROM emp e FULL OUTER JOIN dept d on (e.deptno=d.deptno) ORDER BY e.deptno;
Instructor Note
Demo: l4ojoin.sql
Purpose: To illustrate an outer join.
- 上一篇: 外连接基于Oracle-SQL语言基础
- 下一篇: 第五部分-SQL语言基础