?
Solved

Alternative to FULL OUTER JOIN

Posted on 2008-10-24
7
Medium Priority
?
1,285 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 100 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 37

Assisted Solution

by:momi_sabag
momi_sabag earned 100 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 100 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

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…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

741 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