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
SQL

Avatar of undefined
Last Comment
holemania
ASKER CERTIFIED SOLUTION
Avatar of harfang
harfang
Flag of Switzerland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of holemania
holemania

ASKER

Thanks that'll work.
SQL
SQL

SQL (Structured Query Language) is designed to be used in conjunction with relational database products as of a means of working with sets of data. SQL consists of data definition, data manipulation, and procedural elements. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.

61K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo