Now You Try It
The Human Resources department needs information about divisions. They have asked you for a list of division descriptions and division heads by name.
Enter a SELECT statement to display each division description and employee last and first name.
What tables do you need to join?
You need to join the DIVISION and EMPLOYEE tables.
What are the common columns?
DIV_HEAD_ID in the DIVISION table and EMP_ID in the EMPLOYEE table are the common columns.
The result looks like this:
DIV_CODE DIV_NAME EMP_ID EMP_LNAME EMP_FNAME -------- -------- ------ --------- --------- D06 SERVICE 4321 Bradley George D04 NEW CARS 2010 Parker Cora D09 CORPORATE 1003 Baldwin James D02 USED CARS 2180 Albertini Joan 4 rows processed
If your results do not match what you see above, check Review Answers for Chapter 6 for the correct SQL syntax. Remember that result tables may be shortened in this guide.
Why Include the Join Condition
Without the join condition in the WHERE clause, the request would return a huge table containing every possible row combination from the tables being joined. This type of join is called a Cartesian product. It is very inefficient and contains a great deal of redundant information.
|
Copyright © 2014 CA.
All rights reserved.
|
|