Solved

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

Posted on 2014-01-08
5
228 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now