从源导入时的MS访问标记列

时间:2018-02-01 15:50:57

标签: sql ms-access

我试图将这两个表中的数据导入到这样的导入中:

SELECT * INTO Complaints FROM( 
    SELECT *
    FROM Received2017 
UNION ALL
    SELECT *
    FROM Resolved2017
) 

但是,我无法区分这些数据。所以理想情况下我想要一个专栏来说"输入"我可以标记它是收到还是解决,取决于它被拉出来的表格。

有没有这样做?

2 个答案:

答案 0 :(得分:1)

只需在你的联盟中添加一个常量列:

SELECT * INTO Complaints FROM( 
    SELECT *, "Received" As [Type]
    FROM Received2017 
UNION ALL
    SELECT *, "Resolved" As [Type]
    FROM Resolved2017
) 

答案 1 :(得分:1)

位于which列:

SELECT r.* INTO Complaints
FROM ((SELECT r.*, "received" as which
       FROM Received2017 as r
      ) UNION ALL
      (SELECT r.*, "resolved" as which
       FROM Resolved2017 as r
      )
     ) as r;