简体   繁体   English

从源导入的MS访问标记列

[英]MS access tagging column on import from source

I'm trying to bring in the data from two tables into one on an import like this: 我正在尝试将两个表中的数据导入到一个这样的导入中:

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

However I can't differentiate this data. 但是我无法区分这些数据。 So ideally I want a column saying "type" where I can tag if it was a received or a resolved depending on which table it was pulled form. 因此,理想情况下,我希望有一列“ type”(类型)的列,在该列中可以根据是从哪个表提取表单来标记它是已接收还是已解析。

Is there anyway to do this? 反正有这样做吗?

Just add a constant column in your union: 只需在您的联合中添加一个常量列即可:

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

Just at a which column: 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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM