?
Solved

DB2 Outer Join

Posted on 2001-09-16
2
Medium Priority
?
2,136 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 300 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

770 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