文件名称:使用外连接-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2024-05-15 13:24:58
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.