Solved

DB2 Outer Join

Posted on 2001-09-16
2
2,117 Views
Last Modified: 2011-09-20
Does anyone know that if DB2 supports outer join syntax other than the
ANSI standard ("LEFT OUTER JOIN tableX ON ")? like the one in MSSQL(" *=
") or the one in ORACLE (" =(+) ").

or it ONLY supports ANSI standard outer join?
0
Comment
Question by:cliffordhui
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Expert Comment

by:dilligaffuq
ID: 6487708
Examples of Joins
 

This example illustrates the results of the various joins using tables J1 and J2. These tables contain rows as shown.

   SELECT * FROM J1
 
   W   X    
   --- ------
   A       11
   B       12
   C       13
 
   SELECT * FROM J2
 
   Y   Z    
   --- ------
   A       21
   C       22
   D       23

The following left outer join will get back the missing row from J1 with nulls for the columns of J2. Every row from J1 is included.

   SELECT * FROM J1 LEFT OUTER JOIN J2 ON W=Y
 
   W   X      Y   Z    
   --- ------ --- ------
   A       11 A       21
   B       12 -        -
   C       13 C       22

The following right outer join will get back the missing row from J2 with nulls for the columns of J1. Every row from J2 is included.

   SELECT * FROM J1 RIGHT OUTER JOIN J2 ON W=Y
 
   W   X      Y   Z    
   --- ------ --- ------
   A       11 A       21
   C       13 C       22
   -        - D       23

The following full outer join will get back the missing rows from both J1 and J2 with nulls where appropriate. Every row from both J1 and J2 is included.

   SELECT * FROM J1 FULL OUTER JOIN J2 ON W=Y
 
   W   X      Y   Z    
   --- ------ --- ------
   A       11 A       21
   C       13 C       22
   -        - D       23
   B       12 -        -

This was found at:
http://www-4.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/techlib.d2w/report
with "outer" as the search critera, then click DB2 SQL Reference and click the first example.

dill


0
 
LVL 5

Accepted Solution

by:
kelfink earned 150 total points
ID: 6491272
DB2 only supports the ANSI syntax.  There are subtle differences between the LEFT/RIGHT OUTER JOIN syntax, and the way either Oracle or SqlServer handle their proprietary syntaxes.  Both Sybase and SqlServer handle the ANSI syntax.  I often wish Oracle did.

I still occasionally refer to this comment Joe Celko posted on comp.databases.sybase.  It seems to cover the topic best.

http://groups.google.com/groups?q=celko+*%3D+left+outer+join&hl=en&rnum=3&selm=8j946f%24djv%241%40nnrp1.deja.com

hth,
Kevin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic Table mySQL stored procedure 5 61
Problem Backingh Up Transaction Log on Old SQL000 Database 3 39
sql views 3 50
Intermittent OleDbConnection Error 20 44
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question