Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have three tables.table 1id typeaaa 1bbb 1ccc 1table 2ddd 2eee 2aaa 2table 3fff 3bbb 3ddd 3Output would be :aaa 1 2 nullbbb 1 null 3ccc 1 null nullddd null 2 3eee null 2 nullfff null null 3How can I get this output? I am lost on this one. There is no master table so I don't have any base to compare to transaction tables.
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2011-06-16 : 14:33:50
You can do a full join as in:
select coalesce(t1.id,t2.id,t3.id) as ID, t1.[type], t2.[type], t3.[type]from Table1 t1 full join Table2 t2 on t1.id = t2.id full join Table3 t3 on t3.id = t1.id