SQL Union Query - include table name as field?

T

Titian

Greetings

For a union query of two tables, is it possible to include the name of the
table as an additional field for each record, so that I know from which
table a record has come?

What would be the sql code to do that?

thanks
Dan
 
D

Duane Hookom

SELECT "tblA" as TableName, Field1, Field2
FROM tblA
UNION
SELECT "tblB", Field1, Field2
FROM tblB
UNION
SELECT "tblN", Field1, Field2
FROM tblN;
 
Top