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.
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:
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.