How to differenciate the data when doing a UNION on 2 SELECTS ?

Posted by wiooz on Stack Overflow See other posts from Stack Overflow or by wiooz
Published on 2010-05-19T13:51:42Z Indexed on 2010/05/19 14:00 UTC
Read the original article Hit count: 507

Filed under:
|
|

If I have the following two tables :

Employes

Bob
Gina
John

Customers

Sandra
Pete
Mom

I will do a UNION for having :

Everyone

Bob
Gina
John
Sandra
Pete
Mom

The question is : In my result, how can I creat a dumn column of differenciate the data from my tables ?

Everyone

Bob (Emp)
Gina (Emp)
John (Emp
Sandra (Cus)
Pete (Cus)
Mom (Cus)

I want to know from with table the entry is from withouth adding a new column in the database...

SELECT Employes.name
FROM Employes
UNION
SELECT Customers.name
FROM Customers;

© Stack Overflow or respective owner

Related posts about mysql

Related posts about union