Solved

DB2 Outer Join

Posted on 2001-09-16
2
2,061 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
2 Comments
 
LVL 4

Expert Comment

by:dilligaffuq
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now