Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return table name also

Status
Not open for further replies.

Kaz888

IS-IT--Management
Jul 26, 2002
40
0
0
AU
I am using a SELECT UNION ALL query.

The query looks at 6 specific tables and returns the records in each table that have a status of 1.

At present, the query returns a list of records(sometimes only 2 records), but I then need to go into each of the tables to identify them eg one is an invoice, one is a cheque.

How can I get the table name to show for each record?
Or am I better of separating the query and running them individually?

Thanks in advance,

Kaz
 
Just build the table name into the query!

SELECT "Table1" as TableName, field1, ...
FROM Table1

UNION

SELECT "Table2" as TableName, field1, ...
FROM Table2


Ken
 
Thankyou Ken

Works a treat!

I should have posted to the forum earlier,
instead of wasting 2 days.

Many thanks

Kaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top