If I have these two tables:
resto_name | city Resto A | Paris
resto_name | city Resto B | Doha
If I combine two tables like this:
select * from *Table 1* union select * from *Table 2* resto_name | city Resto A | Paris Resto B | Doha
How will I be able to know that Resto A came from Table 1 and Resto B came from Table 2?
I need to save the selected data to another Table.
This is the expected output on Table 3:
resto_name | city | on_table_one | on_table_two Resto A | Paris | True | False Resto B | Doha | False | True
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
select *, 1 as on_table_one, 0 as on_table_two from table_1 union select *, 0, 1 from table_2