0% found this document useful (0 votes)
2 views11 pages

DBMS

The document provides an overview of SQL joins, detailing four types: Inner Join, Left Outer Join, Right Outer Join, and Full Outer Join. Each type is explained with examples, illustrating how they retrieve records from two tables based on matching keys. The document concludes with a thank you note.

Uploaded by

a.yoganathan a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views11 pages

DBMS

The document provides an overview of SQL joins, detailing four types: Inner Join, Left Outer Join, Right Outer Join, and Full Outer Join. Each type is explained with examples, illustrating how they retrieve records from two tables based on matching keys. The document concludes with a thank you note.

Uploaded by

a.yoganathan a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

SQL JOINS

M.SANTHOSHKUMAR,SANTHOSH,SANGEETH
Types of
Joins
• Inner Join
• Left (Outer) Join
• Right (Outer) Join
• (Full) Outer Join
Inner
Join • Inner join produces
only the set of
records that match in
both Table A and
Table B
• Most commonly
used, best
understood join
Inner
Join
Table
A PK
Table
B PK Value
Value
FOX 1 1 TROT
COP 2 2 CAR
TAXI 3 3 CAB
WASHINGTON 6 6 MONUMENT
DELL 7 7 PC

SELECT * FROM TableA INNER JOIN TableB ON


TableA.PK = TableB.PK
• This is the same as doing
SELECT * FROM TableA, TableB WHERE TableA.PK =
TableB.PK
Left Outer
Join
• Left outer join
produces a complete
set of records from
Table A, with the
matching records
(where available) in
Table B. If there is no
match, the right
side will contain
null.
Left Outer
Join
Table
A
Value
PK
Table
B PK Value

FOX 1 1 TROT
COP 2 2 CAR
TAXI 3 3 CAB
LINCOLN 4 NULL NULL
ARIZONA 5 NULL NULL
WASHINGTON 6 6 MONUMENT
DELL 7 7 PC
LUCENT 10 NULL NULL

• SELECT * FROM TableA LEFT OUTER JOIN TableB


ON TableA.PK = TableB.PK
Right Outer
Join
• Right outer join
produces a complete
set of records from
Table B, with the
matching records
(where available) in
Table A. If there is no
match, the left side
will contain null.
Right Outer
Join
Table
A
Value
PK
Table
B PK Value

FOX 1 1 TROT
COP 2 2 CAR
TAXI 3 3 CAB
WASHINGTON 6 6 MONUMENT
DELL 7 7 PC
NULL NULL 8 MICROSOFT
NULL NULL 9 APPLE
NULL NULL 11 SCOTCH

• SELECT * FROM TableA RIGHT OUTER JOIN


TableB ON TableA.PK = TableB.PK
Full Outer
Join
• Full outer join
produces the set of
all records in Table A
and Table B, with
matching records
from both sides
where available. If
there is no match,
the missing side will
contain null.
Full Outer
TableA TableB
Join
Value
FOX
PK
1
PK
1
Value
TROT
COP 2 2 CAR
TAXI 3 3 CAB
LINCOLN 4 NULL NULL
ARIZONA 5 NULL NULL
WASHINGTON 6 6 MONUMENT
DELL 7 7 PC
LUCENT 10 NULL NULL
NULL NULL 8 MICROSOFT
NULL NULL 9 APPLE
NULL NULL 11 SCOTCH
• SELECT * FROM TableA FULL OUTER JOIN TableB ON TableA.PK
= TableB.PK
THANK YOU

You might also like