Solved

Alternative to FULL OUTER JOIN

Posted on 2008-10-24
7
1,283 Views
Last Modified: 2012-05-05
1) We have DB2 V5R3 on iseries AS/400.
2) FULL OUTER JOIN is not supported
3) There is a query we have written with repeating WHERE conditions for LEFT OUTER JOIN UNION RIGHT OUTER JOIN.
4) Can we not write in a single query without repeating WHERE conditions?
0
Comment
Question by:k_murli_krishna
[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
7 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 25 total points
ID: 22802217
4) no.
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 22803500
Maybe there is a workarond, please post hte whole SQL query here
0
 
LVL 17

Author Comment

by:k_murli_krishna
ID: 22806981
SELECT e.EMPNO, e.ENAME, d.DEPTNO, d.DEPTNAME FROM EMP e LEFTOUTER JOIN DEPT d ON e.DEPTNO = d.DEPTNO WHERE e.ENAME = 'SCOTT' AND d.DEPTNAME = 'MECH' ORDER BY e.EMPNO
UNION
SELECT e.EMPNO, e.ENAME, d.DEPTNO, d.DEPTNAME FROM EMP e RIGHT OUTER JOIN DEPT d ON e.DEPTNO = d.DEPTNO WHERE e.ENAME = 'SCOTT' AND d.DEPTNAME = 'MECH' ORDER BY e.EMPNO;

Also:
SELECT e.EMPNO, e.ENAME, d.DEPTNO, d.DEPTNAME FROM EMP e LEFTOUTER JOIN DEPT d ON e.DEPTNO = d.DEPTNO WHERE e.ENAME = 'SCOTT' AND d.DEPTNAME = 'MECH' ORDER BY e.EMPNO
UNION
SELECT e.EMPNO, e.ENAME, d.DEPTNO, d.DEPTNAME FROM EMP e RIGHT OUTER JOIN DEPT d ON e.DEPTNO = d.DEPTNO WHERE e.ENAME = 'BRENT' AND d.DEPTNAME = 'ELEC' AND e.SAL > 8000 ORDER BY d.DEPTNO;

Maybe IN and NOT IN can be made use of. For multiple columns IN and NOT IN which was also not supported, joins were used as an alternative.
0
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
LVL 37

Assisted Solution

by:momi_sabag
momi_sabag earned 25 total points
ID: 22807588
you could try to have a join with no join conditions (carthesian join) but your solution would probably run faster
0
 
LVL 17

Author Comment

by:k_murli_krishna
ID: 22808118
But, momi, the results would be bloated and not what they should be. Suggest a correct solution else no idea/next to impossible/not possible like angelIIl from one of you is also good enough.
0
 
LVL 16

Assisted Solution

by:theo kouwenhoven
theo kouwenhoven earned 25 total points
ID: 22808945
Did you tried what the performance is/was with a "not in (select....)" ?
0
 
LVL 17

Author Comment

by:k_murli_krishna
ID: 22809647
Thanks, I will try now.
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

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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