Database Programming: Review of Joins
Database Programming: Review of Joins
Database Programming: Review of Joins
Review of Joins
Review of Joins
Objectives
This lesson covers the following objectives: Determine the correct join syntax to use given a scenario requiring the join of data from two or more tables.
Review of Joins
Purpose
Knowing when to use the correct join syntax to meet the needs stated in a business scenario requiring the join of data is very important to your success. This lesson will afford you the opportunity to review the join syntax.
Review of Joins
Classroom Activity
Try the examples listed on the following slides. Confirm that your results match the expected result. If you need help, ask another student or your teacher. All example code is based on the Oracle database. Cross Join
SELECT last_name, department_name FROM employees CROSS JOIN departments;
Review of Joins
Joins by column names and data types that are identical in each table. Both the employees and departments tables have the columns department_id and manager_id. Therefore, the query will return the rows where the values in both columns match.
Review of Joins
Joins by column names and data types that are identical in each table but the USING statement limits to one column.
Review of Joins
Review of Joins
This displays the grade level for each employee based on salary.
Review of Joins
Retrieves all data in the right table (DEPARTMENTS). Returns departments with employees as well as departments without employees.
Review of Joins
Retrieves all data in the left table (EMPLOYEES). Returns employees who are assigned to a department as well as employees who are not assigned to a department.
10
Review of Joins
Retrieves all data in the left table and all data in the right table. This includes departments with employees as well as departments without employees. It also includes employees who are assigned to a department as well as employees who are not assigned to a department.
11
Review of Joins
Summary
In this lesson, you should have learned how to: Determine the correct join syntax to use given a scenario requiring the join of data from two or more tables
12