Skip to content
Advertisement

Adding a column to pull in name of the table in union query

I have 2 queries that I want to combine before exporting to Excel. I used a UNION query to do so, which worked great. Now I want to create a column that says the name of the table it came from. What would be the best way to do this? In the 2 separate queries or the joined query?

For reference:

Advertisement

Answer

Please try the query below:

EDIT:

You can use “group by” after using your first query as a subquery like below:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement