How to OUTER JOIN this?

Tomkat53

Board Regular
Joined
Oct 22, 2010
Messages
61
Excel won't let me do outer joins graphically (with more than 2 tables), but I know it can be done non-graphically, I just don't know how.
Here's what I have so far...

1711555091391.png


Here's the SQL for it...

SQL:
SELECT XXXRE60P.RBDTYR, XXXRE50P.RBMDNO, XXXRE06P.RMDNAM, XXXRE60P.RBDCTL, XXXRE50P.RBMON1, XXXRE50P.RBMON2, XXXRE50P.RBMOA1, XXXRE50P.RBMOA2, XXXRE50P.RBMOA3, XXXRE50P.RBMOCT, XXXRE50P.RBMOST, XXXRE50P.RBMOZP, XXXRE50P.RBMLUC, XXXRE50P.RBMSST, XXXRE50P.RBMSD1, XXXRE50P.RBMPD1, XXXRE50P.RBMPD2, XXXRE50P.RBMPD3, XXXRE50P.RBMCPV, XXXRE50P.RBMCLV, XXXRE50P.RBMCIV, XXXRE50P.RBMCMV, XXXRE50P.RBMCTV, XXXRE50P.RBMTXE, XXXRE50P.RBMACR, XXXRE60P.RBDTTC, XXXRE60P.RBDDSA, XXXRE60P.RBDFCA, XXXRE60P.RBDPNA, XXXRE60P_1.RBDTTC, XXXRE60P_1.RBDDSA, XXXRE60P_1.RBDFCA, XXXRE60P_1.RBDPNA, XXXRE60P_2.RBDTTC, XXXRE60P_2.RBDDSA, XXXRE60P_2.RBDFCA, XXXRE60P_2.RBDPNA, XXXHF60P.HFDFCA

FROM S1029086.IC1ASLIB.XXXHF60P XXXHF60P, S1029086.IC1ASLIB.XXXRE06P XXXRE06P, S1029086.IC1ASLIB.XXXRE50P XXXRE50P, S1029086.IC1ASLIB.XXXRE60P XXXRE60P, S1029086.IC1ASLIB.XXXRE60P XXXRE60P_1, S1029086.IC1ASLIB.XXXRE60P XXXRE60P_2

WHERE XXXRE60P_1.RBDCTL = XXXRE60P.RBDCTL AND XXXRE60P_1.RBDTYR = XXXRE60P.RBDTYR AND XXXRE60P_2.RBDCTL = XXXRE60P.RBDCTL AND XXXRE60P_2.RBDCTL = XXXRE60P_1.RBDCTL AND XXXRE60P_2.RBDTYR = XXXRE60P.RBDTYR AND XXXRE60P_2.RBDTYR = XXXRE60P_1.RBDTYR AND XXXRE50P.RBMCTL = XXXRE60P.RBDCTL AND XXXRE06P.RMDDNO = XXXRE50P.RBMDNO AND XXXHF60P.HFDCTL = XXXRE60P_2.RBDCTL AND XXXHF60P.HFDTYR = XXXRE60P_2.RBDTYR AND XXXHF60P.HFDTTC = XXXRE60P_2.RBDTTC AND ((XXXRE60P.RBDTYR=?) AND (XXXRE60P.RBDTTC=100) AND (XXXRE60P_1.RBDTTC=200) AND (XXXRE60P_2.RBDTTC=300))
ORDER BY XXXRE60P.RBDCTL

This works fine WITHOUT Table XXXHF60P (the table on the far right)
Once I add that table and joins, I LOSE records from my results because the number of records in each table aren't the same.

I need to KEEP ALL records from XXXRE60P_2 and return ONLY records from XXXHF60P where the joins match.
Which means I will have some records with NULL values for fields that I select from XXXHF60P (such as XXXHF60P.HFDFCA) but that's ok, that's what I need.

Is this something that can be done just strictly via the SQL, without the graphical joins?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Don't know if you can achieve this by editing your own sql like you can in Access (which allows GUI outer joins) but maybe try

LEFT JOIN XXXRE60P_2 ON XXXRE60P_2.RBDCTL = XXXHF60P.HFDCTL

However, it looks like you'll need 2 AND statements as well (for the other joins).
 
Upvote 0

Forum statistics

Threads
1,224,847
Messages
6,181,354
Members
453,033
Latest member
lapmangviettel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top