什么是等连接?-SQL语言基础

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

文件名称:什么是等连接?-SQL语言基础

文件大小:5.26MB

文件格式:PPT

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

SQL 基础

什么是等连接? * EMP DEPT EMPNO ENAME DEPTNO ------ ------- ------- 7839 KING 10 7698 BLAKE 30 7782 CLARK 10 7566 JONES 20 7654 MARTIN 30 7499 ALLEN 30 7844 TURNER 30 7900 JAMES 30 7521 WARD 30 7902 FORD 20 7369 SMITH 20 ... 14 rows selected. DEPTNO DNAME LOC ------- ---------- -------- 10 ACCOUNTING NEW YORK 30 SALES CHICAGO 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 30 SALES CHICAGO 30 SALES CHICAGO 30 SALES CHICAGO 30 SALES CHICAGO 20 RESEARCH DALLAS 20 RESEARCH DALLAS ... 14 rows selected. 外键 主键 * Equijoins To determine the name of an employee’s department, you compare the value in the DEPTNO column in the EMP table with the DEPTNO values in the DEPT table. The relationship between the EMP and DEPT tables is an equijoin—that is, values in the DEPTNO column on both tables must be equal. Frequently, this type of join involves primary and foreign key complements. Note: Equijoins are also called simple joins or inner joins. Instructor Note Explain the use of decision matrix for simplifying writing joins. For example, if you want to display the name and department number of all the employees who are in the same department as Smith, you can start by making the following decision tree: Now the SQL statement can be easily formulated by looking at the decision matrix. The first column gives the column list in the SELECT statement, the second column gives the tables for the FROM clause, and the third column gives the condition for the WHERE clause.


网友评论