differernce between outer and inner joins

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

differernce between outer and inner joins

Post by bugthefixer »

I wonder if anybody could help me with inner and outer joins, what is the exact difference
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I'll give an example:

tableA:
(1, tim)
(2, mike)
(3, john)

tableB:
(1, van wassenhove)
(2, myers)
(4, doe)


tableA INNER JOIN tableB USING id
(1, tim, van wassenhove)
(2, mike, myers)

tableA LEFT OUTER JOIN tableB USING id
(1, tim, van wassenhove)
(2, mike, myers)
(3, john, NULL)

tableA RIGHT OUTER JOIN tableB USING id
(1, tim, van wassenhove)
(2, mike, myers)
(4, NULL, doe)

tableA FULL OUTER JOIN tableB USING id
(1, tim, van wassenhove)
(2, mike, myers)
(3, john, NULL)
(4, NULL, doe)
Post Reply