troubleshooting Question

Query - Full Join

Avatar of holemania
holemania asked on
SQL
2 Comments1 Solution399 ViewsLast Modified:
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
harfang

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros