问题描述
我有3个表,它们具有相同的列。
FY2015
A B C
0 1 2
1 2 3
2 3 4
FY2016
A B C
3 4 5
4 5 6
7 8 9
FY2017
A B C
1 3 5
2 4 6
3 6 9
创建表FY_ALL的最佳方法是什么?
FY_ALL
A B C
0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
7 8 9
1 3 5
2 4 6
3 6 9
解决方法
您想要union all
:
select a,b,c from FY2015 union all
select a,c from FY2016 union all
select a,c from FY2017;
您可以使用create table as
或insert into
来填充另一个表(取决于该表是否已经存在)。