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!

Selecting the Tablename in a UNION

Status
Not open for further replies.

jl8789

MIS
May 22, 2003
293
0
0
US
First post in this forum, so please help and be kind!

I have a UNION of two different tables that basically contain the same information. What I want to know is how can I select the tablename from the query so when I display the results I know which table the row came from?

Thanks!
 
Insert literally the table name on every select stm, that is:

select fld1, fld2, ..., 'TABLE1' from table1
union
select fld1, fld2, ..., 'TABLE2' from table2

It's that simple !
 
Thanks. I finally did that, I was trying to think too hard for something so simple.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top