Unioning two tables with different number of columns

后端 未结 5 1368
囚心锁ツ
囚心锁ツ 2020-11-22 11:23

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

5条回答
  •  醉酒成梦
    2020-11-22 11:49

    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
    

提交回复
热议问题