MySql union query with table name
mysql, sql, union
Solution
Add an extra column to your query like
select col1,col2,...,coln,'Table1' as Tablename from table1
Union
select col1,col2,...,coln,'Table2' as Tablename from table2
Problem
I have to write one query that will fetch data from two table. I am using `UNION` and working perfectly. But how can i recognize which row belongs to which table? i want data like this. ``` ================================================== Table Name | Person Name ================================================== table one | xyz -------------------------------------------------- table two | abc -------------------------------------------------- table one | www ```