Oracle UNION different columns

柔情痞子 提交于 2019-12-02 04:19:14

You can try this

SELECT COL_A, COL_B, COL_C FROM Table1
UNION
SELECT COL_A, COL_B, 0 As COL_C FROM Table2
SELECT COL_A,COL_B,COL_C FROM TABLE_1
UNION
SELECT COL_A,COL_B,'0' AS COL_C FROM TABLE_2

You may also be able to get away with

SELECT COL_A,COL_B,COL_C FROM TABLE_1
UNION
SELECT COL_A,COL_B,'0' FROM TABLE_2

The basic idea is that both must have same number of columns of the same corresponding data types.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!