I've got 2 select statements, returning data like this:
Select 1 col_a col_b
Select 2 col_a col_c
If I do union, I get something like col_a col_b
And rows joined. What i need is getting it like this: col_a col_b col_c
Joined on data in col_a.
I've got 2 select statements, returning data like this:
Select 1 col_a col_b
Select 2 col_a col_c
If I do union, I get something like col_a col_b
And rows joined. What i need is getting it like this: col_a col_b col_c
Joined on data in col_a.
Use JOIN to join the subqueries and use ON to say where the rows from each subquery must match:
If there are some values of col_a that are in T1 but not in T2, you can use a LEFT OUTER JOIN instead.
Use a FULL OUTER JOIN: