简体   繁体   中英

Create a new Table in MS Access using an existing SQL query

I have two different tables US and UK in my Access database. I have imported these two tables from two different excel files. Now I am creating a query for Union of these two tables and query runs perfectly. My query is given below:

SELECT ID,Month,Year,Country
From UK
ORDER BY ID;
UNION SELECT ID,Month,Year,Country
From US;

Now I want to create a new Table where the out put of the above query will store. I want to write a SQL code for that. I am totally new in Sql so need help to resolve it.

Simply run a make-table query which involves the INTO clause in MS Access SQL. Also, place UNION query in a subquery derived table:

SELECT ID, [Month], [Year], [Country]
INTO myNewTable
FROM (
    SELECT ID, [Month], [Year], [Country]
    FROM [UK]
    UNION ALL
    SELECT ID, [Month], [Year], [Country] 
    FROM [US]
) sub
ORDER BY [ID]

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.

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