-
使用等号连接来获取记录-入门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.
- 上一篇: Access数据库设计基础PPT教程
- 下一篇: 使用表的别名-SQL语言基础