Link to home
Start Free TrialLog in
Avatar of holemania
holemania

asked on

Query - Full Join

Hello experts,

I have a simple query that I can't seem to get it to work correctly.  I have a table that has just one field call "CODE".  This is query between 3 databases, so I need to be able to order them in sequence and have it ouput side by side.  All 3 databases has same table and 1 field call "CODE".

Example:

DB1          DB2            DB3
AAB1         AAB1          AAB1
BB32         NULL          BB32
CDB4         NULL          NULL
NULL         NULL          DDEF3
JJL12          JJL12           NULL

I  tried the following, but can't seem to sort correctly.

SELECT D1.CODE AS DB1, D2.CODE AS DB2, D3.CODE AS DB3
FROM  DB1.DBO.PRODUCT D1 FULL OUTER JOIN DB2.DBO.PRODUCT D2
            ON D1.CODE = D2.CODE FULL OUTER JOIN DB3.DBO.PRODUCT D3
             ON D2.CODE = D3.CODE OR D1.CODE = D3.CODE
ASKER CERTIFIED SOLUTION
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of holemania
holemania

ASKER

Thanks that'll work.