用等连接获取记录-SQL语言基础

时间:2024-05-15 13:24:57
【文件属性】:

文件名称:用等连接获取记录-SQL语言基础

文件大小:5.26MB

文件格式:PPT

更新时间:2024-05-15 13:24:57

SQL 基础

用等连接获取记录 * SQL> SELECT emp.empno, emp.ename, emp.deptno, 2 dept.deptno, dept.loc 3 FROM emp, dept 4 WHERE emp.deptno=dept.deptno; EMPNO ENAME DEPTNO DEPTNO LOC ----- ------ ------ ------ --------- 7839 KING 10 10 NEW YORK 7698 BLAKE 30 30 CHICAGO 7782 CLARK 10 10 NEW YORK 7566 JONES 20 20 DALLAS ... 14 rows selected. * SELECT emp.empno, emp.ename, emp.deptno, dept.deptno, dept.loc FROM emp, dept WHERE emp.deptno=dept.deptno; Retrieving Records with Equijoins In the slide example: The SELECT clause specifies the column names to retrieve: employee name, employee number, and department number, which are columns in the EMP table department number, department name, and location, which are columns in the DEPT table The FROM clause specifies the two tables that the database must access: EMP table DEPT table The WHERE clause specifies how the tables are to be joined: EMP.DEPTNO=DEPT.DEPTNO Because the DEPTNO column is common to both tables, it must be prefixed by the table name to avoid ambiguity.


网友评论