Solved

DB2 Outer Join

Posted on 2001-09-16
2
2,110 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Documenting Data flow 4 55
A beginner asks: Which macos postgreSQL client? 5 85
Access 2016 Query with Proper Case logic 2 48
SQL Query help 3 40
Read about achieving the basic levels of HRIS security in the workplace.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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…

761 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