Keep name of source query in Union

  • Thread starter William McNeill
  • Start date
W

William McNeill

I have created a Union query combining the queries CEg, CMg, CSg, and CWg.
Works great. I need to know if there is any way to keep the name of the
source quiery in the rows of the Union query to identify where that record
came from. Thanks!!!!
 
R

Rob Parker

Hi William,

Easily done, by adding an additional field and setting the value in each
part of the union query. Something like:

SELECT Field1, Field2, "CEg" AS FromQuery FROM CEg
UNION
SELECT Field1, Field2, "CMg" AS FromQuery FROM CMg
....

HTH,

Rob
 
Top