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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Best Join to use

Author  Topic 

lejanco
Starting Member

8 Posts

Posted - 2014-12-29 : 13:22:29
Hello,

I have a question about the best join to use for a query. I have 10 tables and about 5000 rows/ primary keys and 52 columns. However, not every primary key is in every table, but I need to have all of them combined into one table with all the distinct primary keys from each table and all 52 columns. I have used a full outer join, but that takes a lot of extra manipulation once I copy to excel. Would a left join be better? Please let me know if I need to include attachments.

Thanks,
Laura

Laura Janco

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-12-29 : 13:31:12
Using a full outer join or a left join is dependent upon your table design and what you want to see. They are not equivalent. You don't pick one over the other due to performance. You pick one over the other because one is required to produce the correct output. A full outer join is a left and right outer join. So if you switch to just left join, you are missing the right join data.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -