Search code examples
ms-accessunion-all

Union Query In Separate Databases


I have 2 databases. In database1, I want to run a query from database2 and UNION ALL the results. This is the syntax I tried, but I get an error of

Syntax error in from clause

Here is the syntax I tried --- where is my error?

SELECT * FROM query1
UNION ALL
SELECT * FROM query1 IN C:\Database\production.mdb

Solution

  • Add quotes around the path of the external database.

    I would also use aliases to distinguish between the 2 instances of query1.

    SELECT q1Local.* FROM query1 AS q1Local
    UNION ALL
    SELECT q1Remote.* FROM query1 AS q1Remote IN 'C:\Database\production.mdb'