Log in

View Full Version : Resolved UNION -- identifying the table used.



james438
05-06-2010, 11:53 PM
(select ID, title from table1 order by ID asc limit 10)
UNION
(select ID, title from table2 order by ID asc limit 10)

Using php or MySQL how can you match the results with the table it was retrieved from?

james438
05-07-2010, 12:29 AM
(select ID, title, table1 AS col1 from table1 order by ID asc limit 10)
UNION
(select ID, title, table2 AS col1 from table2 order by ID asc limit 10)

solved the problem where col1 is just a dummy column name.