Upload
amos-baker
View
40
Download
5
Embed Size (px)
DESCRIPTION
The Inner Join and Outer Joins. Dec 15 2004. Dancing and Tennis. Dancing only. Tennis Only. The Whole Picture. A. B,D,F. C. G. The Inner Join. B,D,F. Inner. The Left Outer Join. A. B,D,F. G. Left. Inner. The Right Outer Join. B,D,F. C. Right. Inner. The Full Outer Join. - PowerPoint PPT Presentation
Citation preview
The Inner Join and Outer Joins
Dec 15 2004
Dance.DBF Tennis.DBF
scode scodeA BB CD DF FG
Studentswho jointhedancinggroup
Studentswho jointhe tennisgroup
ABC School
B,D,FA
G
C
Dancing and
Tennis
Dancing onlyTennis Only
The Whole Picture
B,D,F
The Inner Join
Inner
B,D,FA
G
The Left Outer Join
Left Inner
B,D,F C
The Right Outer Join
RightInner
B,D,FA
G
C
The Full Outer Join
Left RightInner
A
G
C
The Exclusive Join
Left Right
Dance.DBF Tennis.DBF
scode scodeA BB CD DF FG
Studentswho jointhedancinggroup
Studentswho jointhe tennisgroup
ABC School
Using Plausible
Keys
To link
The tables together
…. dance ____ JOIN tennis ON dance.scode=tennis.scode
B,D,F
The Inner Join
Inner
SELECT *
FROM dance inner join tennis
On dance.scode=tennis.scode
B,D,FA
G
The Left Outer Join
Left Inner
SELECT *
FROM dance left outer join tennis
On dance.scode=tennis.scode
B,D,F C
The Right Outer Join
RightInner
SELECT *
FROM dance right outer join tennis
On dance.scode=tennis.scode
B,D,FA
G
C
The Full Outer Join
Left RightInner
SELECT *
FROM dance full outer join tennis
On dance.scode=tennis.scode
A
G
C
The Exclusive Join
Left Right
SELECT *
FROM dance full outer join tennis
On dance.scode=tennis.scode
Where dance.scode is .null. Or tennis.scode is .null.
Court1
Court2
3:30 – 4:00 Session A
4:00 – 4:30 Session B
udate session udate session
12/13/2004 A 12/13/2004 B12/14/2004 B 12/14/2004 A12/15/2004 A 12/14/2004 B12/15/2004 B 12/15/2004 B12/17/2004 B 12/16/2004 A
Court1.DBF Court2.DBF
Basket Ball Court1. Itshows the dates and thesessions when Court1 isbooked.
Basket Ball Court2. Itshows the dates and thesessions when Court2 isbooked.
JCCSS(Tuen Mun)
Keys for Sessions: udate+session
udate session udate session
12/13/2004 A 12/13/2004 B12/14/2004 B 12/14/2004 A12/15/2004 A 12/14/2004 B12/15/2004 B 12/15/2004 B12/17/2004 B 12/16/2004 A
Court1.DBF Court2.DBF
Basket Ball Court1. Itshows the dates and thesessions when Court1 isbooked.
Basket Ball Court2. Itshows the dates and thesessions when Court2 isbooked.
JCCSS(Tuen Mun)
Using Plausible
Keys
To link
The tables together
Keys for Sessions: udate+session
court1____ JOIN court2 ON court1.udate=court2.udate and court1.session=court2.session …..
udate session udate session
12/13/2004 A 12/13/2004 B12/14/2004 B 12/14/2004 A12/15/2004 A 12/14/2004 B12/15/2004 B 12/15/2004 B12/17/2004 B 12/16/2004 A
JCCSS(Tuen Mun)
Court1.DBF Court2.DBF
Basket Ball Court1. Itshows the dates and thesessions when Court1 isbooked.
Basket Ball Court2. Itshows the dates and thesessions when Court2 isbooked.
Using Plausible
Keys
To link
The tables together
Keys for Days:udate
Group By
court1____ JOIN court2 ON court1.udate=court2.udate session …..