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

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

Question by:colinspurs
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 48

Accepted Solution

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"

Author Comment

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

LVL 143

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:
LVL 13

Expert Comment

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

Expert Comment

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.

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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

732 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