Unioning two tables with different number of columns

后端 未结 5 1476
囚心锁ツ
囚心锁ツ 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 12:03

    for any extra column if there is no mapping then map it to null like the following SQL query

    Select Col1, Col2, Col3, Col4, Col5 from Table1
    Union
    Select Col1, Col2, Col3, Null as Col4, Null as Col5 from Table2````
    

提交回复
热议问题