我需要加入两个表格。
Columns A, B, C
Row 1 10, 20, 30
Row 2 40, 50, 60
Columns A, B, D
Row 1 70, 80, 90
Row 2 5, 6, 7
Output should be
Columns A, B, C, D
Row 1 10, 20, 30, null
Row 2 40, 50, 60, null
Row 3 70, 80, null, 90
Row 4 5, 6, null, 7
答案 0 :(得分:0)
select a, b, c, null as d
from table1
union all
select a, b, null as c, d
from table2;
答案 1 :(得分:0)
您只需UNION ALL
select a, b, c, null d from table1
union all
select a, b, null, d from table2