Download presentation
Presentation is loading. Please wait.
Published bySarah Harrison Modified over 8 years ago
1
Chapter 4Introduction to Oracle9i: SQL1 Chapter 4 Joining Multiple Tables
2
Chapter 4Introduction to Oracle9i: SQL2 Chapter Objectives Create a Cartesian join Create an equality join using the WHERE clause Create an equality join using the JOIN keyword Create a non-equality join using the WHERE clause Create a non-equality join using the JOIN…ON approach
3
Chapter 4Introduction to Oracle9i: SQL3 Chapter Objectives Create a self-join Distinguish an inner join from an outer join Create an outer join using the WHERE clause Create an outer join using the OUTER keyword Use set operators to combine the results of multiple queries Join three or more tables
4
Chapter 4Introduction to Oracle9i: SQL4 Purpose of Joins Joins are used to link tables and reconstruct data in a relational database Joins can be created through: –Conditions in a WHERE clause –Use of JOIN keywords in FROM clause
5
Chapter 4Introduction to Oracle9i: SQL5 Cartesian Join Created by omitting joining condition in the WHERE clause or through CROSS JOIN keywords in the FROM clause Results in every possible row combination (m * n)
6
Chapter 4Introduction to Oracle9i: SQL6 Cartesian Join Example: Omitted Condition
7
Chapter 4Introduction to Oracle9i: SQL7 Cartesian Join Example: CROSS JOIN Keywords
8
Chapter 4Introduction to Oracle9i: SQL8 Equality Join Links rows through equivalent data that exists in both tables Created by: –Creating equivalency condition in the WHERE clause –Using NATURAL JOIN, JOIN…USING, or JOIN…ON keywords in the FROM clause
9
Chapter 4Introduction to Oracle9i: SQL9 Equality Join: WHERE Clause Example
10
Chapter 4Introduction to Oracle9i: SQL10 Equality Join: NATURAL JOIN Syntax: tablename NATURAL JOIN tablename
11
Chapter 4Introduction to Oracle9i: SQL11 Equality Join: JOIN…USING Syntax: tablename JOIN tablename USING (columnname)
12
Chapter 4Introduction to Oracle9i: SQL12 Equality Join: JOIN…ON Syntax: tablename JOIN tablename ON condition
13
Chapter 4Introduction to Oracle9i: SQL13 JOIN Keyword Overview Use NATURAL JOIN when tables have one column in common Use JOIN…USING when tables have more than one column in common Use JOIN…ON when a condition is needed to specify a relationship other than equivalency Using JOIN keyword frees the WHERE clause for exclusive use in restricting rows
14
Chapter 4Introduction to Oracle9i: SQL14 Non-Equality Joins In WHERE clause, use any comparison operator other than equal sign In FROM clause, use JOIN…ON keywords with non-equivalent condition
15
Chapter 4Introduction to Oracle9i: SQL15 Non-Equality Join: WHERE Clause Example
16
Chapter 4Introduction to Oracle9i: SQL16 Non-Equality Join: JOIN…ON Example
17
Chapter 4Introduction to Oracle9i: SQL17 Self-Joins Used to link a table to itself Requires use of column qualifier
18
Chapter 4Introduction to Oracle9i: SQL18 Self-Join: WHERE Clause Example
19
Chapter 4Introduction to Oracle9i: SQL19 Self-Join: JOIN…ON Example
20
Chapter 4Introduction to Oracle9i: SQL20 Outer Joins Use to include rows that do not have a match in the other table In WHERE clause, include outer join operator (+) next to table with missing rows to add NULL rows In FROM clause, use FULL, LEFT, or RIGHT with OUTER JOIN keywords
21
Chapter 4Introduction to Oracle9i: SQL21 Outer Join: WHERE Clause Example
22
Chapter 4Introduction to Oracle9i: SQL22 Outer Join: OUTER JOIN Keyword Example
23
Chapter 4Introduction to Oracle9i: SQL23 Set Operators Used to combine the results of two or more SELECT statements
24
Chapter 4Introduction to Oracle9i: SQL24 Set Operator Example
25
Chapter 4Introduction to Oracle9i: SQL25 Joining Three or More Tables Same procedure as joining two tables Will always results in one less join than the number of tables being joined
26
Chapter 4Introduction to Oracle9i: SQL26 Joining Three or More Tables: Example
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.