18
The Inner Join and Outer Joins Dec 15 2004

The Inner Join and Outer Joins

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

Page 1: The Inner Join and Outer Joins

The Inner Join and Outer Joins

Dec 15 2004

Page 2: The Inner Join and Outer Joins

Dance.DBF Tennis.DBF

scode scodeA BB CD DF FG

Studentswho jointhedancinggroup

Studentswho jointhe tennisgroup

ABC School

Page 3: The Inner Join and Outer Joins

B,D,FA

G

C

Dancing and

Tennis

Dancing onlyTennis Only

The Whole Picture

Page 4: The Inner Join and Outer Joins

B,D,F

The Inner Join

Inner

Page 5: The Inner Join and Outer Joins

B,D,FA

G

The Left Outer Join

Left Inner

Page 6: The Inner Join and Outer Joins

B,D,F C

The Right Outer Join

RightInner

Page 7: The Inner Join and Outer Joins

B,D,FA

G

C

The Full Outer Join

Left RightInner

Page 8: The Inner Join and Outer Joins

A

G

C

The Exclusive Join

Left Right

Page 9: The Inner Join and Outer Joins

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

Page 10: The Inner Join and Outer Joins

B,D,F

The Inner Join

Inner

SELECT *

FROM dance inner join tennis

On dance.scode=tennis.scode

Page 11: The Inner Join and Outer Joins

B,D,FA

G

The Left Outer Join

Left Inner

SELECT *

FROM dance left outer join tennis

On dance.scode=tennis.scode

Page 12: The Inner Join and Outer Joins

B,D,F C

The Right Outer Join

RightInner

SELECT *

FROM dance right outer join tennis

On dance.scode=tennis.scode

Page 13: The Inner Join and Outer Joins

B,D,FA

G

C

The Full Outer Join

Left RightInner

SELECT *

FROM dance full outer join tennis

On dance.scode=tennis.scode

Page 14: The Inner Join and Outer Joins

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.

Page 15: The Inner Join and Outer Joins

Court1

Court2

3:30 – 4:00 Session A

4:00 – 4:30 Session B

Page 16: The Inner Join and Outer Joins

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

Page 17: The Inner Join and Outer Joins

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 …..

Page 18: The Inner Join and Outer Joins

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 …..