Can you please tell me how can I determine from which table this id is derived?
SELECT id FROM table_1 UNION SELECT id FROM table_2
table_1
|id|
|1 |
table_2
|id|
|2 |
Through while I got two id (1, 2). How to understand in which table id 1 and in which table id 2?
CodePudding user response:
You could inject your own identifier, such as:
SELECT id, 'T1' as Source
FROM table_1
UNION
SELECT id, 'T2'
FROM table_2