Joining on multiple columns

Database
c19
Enthusiast

Joining on multiple columns

Hi,

I was wondering on a FULL JOIN what the difference between joining on one column and multiple say 10 or more?

Thanks
3 REPLIES
Enthusiast

Re: Joining on multiple columns

Hi,
There is a DIFFERENCE check for the below given analysis:

The concept of Full Outer join is to show data from both tables if matching row found and display NULL if no rows are found.

B
b1 b2 b3
1 1 1
2 2 2
1 3 3
10 1 1

A
a1 a2 a3
1 1 1
2 1 1
1 2 3
1 3 3

you can try out below two queries and test the result, the result differs due to cross join in first query as the Unique Key for table A (a1,a2) and B(b1,b2).

Select A.a1,A.a2,A.a3,B.b1,B.b2,B.b3
FRom
A FULL OUTER JOIN B ON
A.a1=B.b1

Select A.a1,A.a2,A.a3,B.b1,B.b2,B.b3
FRom
A FULL OUTER JOIN B ON
A.a1=B.b1
A.a2=B.b2

From application point of view i would suggest you to put the matching conditions in Full Outer Join for both the tables.

~Vinod
c19
Enthusiast

Re: Joining on multiple columns

Thanks for the reply,

if the any of the conditions fail on joining more than one column does all the columns display a NULL?
Enthusiast

Re: Joining on multiple columns

YES

~vinod