I want to UNION two tables based on a single column.
Assume that, I have a table called t1:
Id | Name
------------
1 | A
2 | B
3 | C
And a second table called t2:
Id | Name
------------
1 | B
3 | B
5 | B
I want to UNION them like this:
SELECT * FROM T1
UNION
SELECT * FROM T2
BASED ON ID
And I expect a result like:
Id | Name
------------
1 | A
2 | B
3 | C
5 | B
If IDs are equal then pick the row from the first table:
Actually, I am working with tables which have 20+ columns. These tables are for demonstration.