tags:

views:

51

answers:

2

I am stuck - I have two tables (Table A and Table B).

These have different number of columns - Say Table A has more columns.

How can I union these two table and get null for the columns that Table B does not have?

+5  A: 

Add extra columns as null for the table having less columns like

Select Col1, Col2, Col3, Col4, Col5 from Table1
Union
Select Col1, Col2, Col3, Null as Col4, Null as Col5 from Table2
Kangkan
A: 

Is it possible to do this any other way?
I need to union rows from 5 different tables each with different numbers of columns and column names...It will take me forever to sort out which select statements need to have which columns nulled.