A join is a type of select in which you request data from more than one table.
Look at the table descriptions for EMPLOYEE and DEPARTMENT in Appendix C, “Table Descriptions.” The EMPLOYEE table carries employee information plus the employee's department ID. The name of the department is not carried in this table.
If you want to see more information about the department, you need to look at the DEPARTMENT table where you find the ID and name of the department. To display both employee and department information at the same time, you need to access both tables at once to join them.
Common Columns
A join can occur when tables have a column in common. Each table must have at least one column that corresponds to a column in at least one other table in the join.
Usually these common columns are planned as part of the database design. In Error! Reference source not found. you read about foreign keys, which are columns or combination of columns in one table corresponding to the primary key of another table. These are planned common columns:
EMPLOYEE ┌────────┬───────────┬───────────┬─────────┐ │EMP_ID │EMP_LNAME │EMP_FNAME │DEPT_ID │ ├────────┼───────────┼───────────┼─────────┤ │2096 │CARLSON │THOMAS │4600 │ │ │ │ │ │ │2437 │THOMPSON │HENRY │4600 │ │ │ │ │ │ │2598 │JACOBS │MARY │5100 │ └────────┴───────────┴───────────┴─┬───────┘ │ │ │ DEPARTMENT │ ┌─────────┬─────────────────────┐ └─────────┤DEPT_ID │DEPT_NAME │ ├─────────┼─────────────────────┤ │5200 │CORPORATE MARKETING │ │ │ │ │4600 │MAINTENANCE │ │ │ │ │5100 │BILLING │ └─────────┴─────────────────────┘
|
Copyright © 2014 CA.
All rights reserved.
|
|