Professional Documents
Culture Documents
Displaying Data
from Multiple Tables
Objectives
4-2
Obtaining Data from Multiple Tables
EMPLOYEES DEPARTMENTS
4-3
Cartesian Products
4-4
Generating a Cartesian Product
EMPLOYEES (20 rows) DEPARTMENTS (8 rows)
Cartesian
product:
20x8=160 rows
…
4-5
Types of Joins
• Equijoin
• Non-equijoin
• Outer join
• Self join
4-6
Joining Tables Using Oracle Syntax
4-7
What is an Equijoin?
EMPLOYEES DEPARTMENTS
… …
4-8
Retrieving Records
with Equijoins
4-9
Additional Search Conditions
Using the AND Operator
EMPLOYEES DEPARTMENTS
… …
4-10
Qualifying Ambiguous
Column Names
4-11
Using Table Aliases
4-12
Joining More than Two Tables
EMPLOYEES DEPARTMENTS LOCATIONS
4-13
Non-Equijoins
EMPLOYEES JOB_GRADES
4-14
Retrieving Records
with Non-Equijoins
4-15
Outer Joins
DEPARTMENTS EMPLOYEES
…
There are no employees in
department 190.
4-16
Outer Joins Syntax
SELECT
SELECT table1.column,
table1.column, table2.column
table2.column
FROM
FROM table1,
table1, table2
table2
WHERE
WHERE table1.column
table1.column == table2.column(+);
table2.column(+);
4-17
Using Outer Joins
4-18
Self Joins
… …
4-19
Joining a Table to Itself
4-20
Practice 4, Part One: Overview
4-21
4-24