[英]Create a new table in SQL based on two other tables
I have two tables against which I would like to create new table with the output.我有两个表,我想用 output 创建新表。
For example;例如;
Table 1表格1
Column 1 Column 2 Column 3
a b c
Table 2表 2
Column 4 Column5 Column6
D E F
I've joined above tables with an "Union".我用“联盟”加入了上面的表格。 Not sure how to create a new table from the original query itself
不确定如何从原始查询本身创建新表
Any help would be appreciated任何帮助,将不胜感激
for creating a new table , use INTO
statement that provide a new table.要创建新表,请使用提供新表的
INTO
语句。 it should be place in the first select它应该放在第一个 select
SELECT column1,
column2,
column3
INTO newtable --creating new table
FROM table1
UNION
SELECT column4,
column5,
column6
FROM table2
If you have created a New Table , then use INSERT INTO
Statement如果您已创建新表,则使用
INSERT INTO
语句
INSERT INTO newtable
(column1,
column2,
column3)
SELECT column1,
column2,
column3
FROM table1
UNION
SELECT column4,
column5,
column6
FROM table2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.