Ton
Ton

Reputation: 1

SQL Server : merge 2 tables

I have a table ONE with data:

Id      v1   V2   
-----------------
1       10   100     
2       15   150     
3       20   200     

and a table TWO with data:

Id     v3   V4   
------------------
1    1000    1000     
2    1500   15000     
3    2000   20000  
4     800   30000

I want to get this result:

Id      v1   V2     v3      V4
----------------------------------
1       10   100    1000    1000   
2       15   150    1500   15000   
3       20   200    2000   20000 
4       null null    800   30000

I tried this SQL code:

SELECT *
FROM [One]
FULL OUTER JOIN [Two] ON [One].ID = [Two].ID  

Upvotes: 0

Views: 102

Answers (1)

Brian
Brian

Reputation: 242

I might be missing something but I think you just need left join

SELECT * 
FROM [TWO] t
LEFT JOIN [ONE] o ON o.Id = t.Id

Upvotes: 1

Related Questions