Solved

SQL joining to a table from two other tables in one go

Posted on 2014-01-08
5
234 Views
Last Modified: 2014-01-08
Hi all,

I have inherited this query from a colleague.  I am not sure whether it is OK / recommended / downright wrong to join to a third table using fields from two other tables in the one join.

Can you advise please?

Thanks,
   Colin
Capture.PNG
0
Comment
Question by:colinspurs
5 Comments
 
LVL 48

Accepted Solution

by:
PortletPaul earned 500 total points
ID: 39764718
It is quite acceptable to join like that.

Hard to give more advice without knowing more about the data & relationships; but is not "wrong"
0
 
LVL 3

Author Comment

by:colinspurs
ID: 39764785
Ok thanks.  I don't see that too often and suspect I have duplicate rows so wanted to verify it.

Cheers
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39764790
I concur that this is perfectly possible (I use i almost every day).

if you have "duplicate rows", you may want to read up this article for explanations and solutions:http://www.experts-exchange.com/Database/Miscellaneous/A_3203-DISTINCT-vs-GROUP-BY-and-why-does-it-not-work-for-my-query.html
0
 
LVL 13

Expert Comment

by:sameer2010
ID: 39764803
Yes, duplicates could be due to "cartesian product" or incorrect logic.
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 39764979
Thanks for the points...

"duplicate rows" usually means "unexpected, and unwanted, repetition" that may not be due to that join. Most often it is many-to-one relationships that are the cause.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question