Skip to content
Advertisement

Oracle SQL merge tables side by side

I have 3 select queries which i would like to merge side by side. The common column is name. I dont want to use UNION ALL solutions since my select queries might have many columns.

name  columna  
e1    1  
name    columnb    
h1      2  
name    columnc
t1      3  

The output i am looking for is:

name columna columnb columnc  
e1   1     
h1           2
t1                   3

I believe I need the full outer join. I tried left outer with (+) syntax.

but the output is:

name columna columnb columnc
e1   1     

Advertisement

Answer

Perhaps you’re after something like the following?:

This uses full outer joins to join the tables together (note the use of the “OR” when joining the third table), and assumes the name column is unique in each table.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement