登录 注册
当前位置:主页 > 资源下载 > 使用等号连接来获取记录-入门SQL语

使用等号连接来获取记录-入门SQL语

  • 更新:2024-07-07 11:33:32
  • 大小:5.26MB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Informix - 数据库
  • 格式:PPT

资源介绍

用等连接获取记录 * 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.