I want to union two tables and add a flag column(1,0) indicating where they came from. Any help on how to perform this SQL?
Just add a static column to your SELECT
SELECT
a
,b
,0 AS flag
FROM
t1
UNION ALL
SELECT
a
,b
,1 AS flag
FROM
t2