This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes inner join     Vs     outer join Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "inner join     Vs     outer join " Watch "inner join     Vs     outer join " New topic

inner join Vs outer join

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1383
What is the difference between inner join and outer join ?
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
- inner joins only returns rows that "match" in both tables
- outer joins return "all" rows from 1st table, and null valued columns in rows that don't exist in the 2nd table

for example, imagine we have this data, also for each query, we join them on column "id":

Also to note, the SQL syntax for outer joins is database vendor specific, Oracle used different notation from say SQL Server.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1383
In Oracle outer join is defined as * symbol. in Sybase outer join is defined as + symbol. What is the outer join symbol for DB2 ?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31588


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
It is sorta covered in the JavaRanch Style Guide.
subject: inner join Vs outer join