Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:38:10+00:00 2026-06-10T22:38:10+00:00

I have been having a hard time googling an answer for this, but…. can

  • 0

I have been having a hard time googling an answer for this, but….
can someone explain to me the difference between putting the ON condition of a JOIN with the the JOIN itself vs putting the ON at the end of all the other JOINs.

here is an example http://sqlfiddle.com/#!3/e0a0f/3

CREATE TABLE TableA (Email VARCHAR(100), SomeNameA VARCHAR(100))
CREATE TABLE Tableb (Email VARCHAR(100), SomeNameB VARCHAR(100))
CREATE TABLE Tablec (Email VARCHAR(100), SomeNameC VARCHAR(100))

INSERT INTO TableA SELECT 'joe@test.com', 'JoeA'
INSERT INTO TableA SELECT 'jan@test.com', 'JaneA'
INSERT INTO TableA SELECT 'dave@test.com', 'DaveA'
INSERT INTO TableB SELECT 'joe@test.com', 'JoeB'
INSERT INTO TableB SELECT 'dave@test.com', 'DaveB'
INSERT INTO TableC SELECT 'joe@test.com', 'JoeC'
INSERT INTO TableC SELECT 'dave@test.com', 'DaveC'


SELECT TOP 2 a.*,
             b.*,
             c.*
FROM   TableA a
       LEFT OUTER JOIN TableB b
                    ON a.email = b.email
       INNER JOIN TableC c
                    ON c.Email = b.email;

SELECT TOP 2 a.*,
             b.*,
             c.*
FROM   TableA a
       LEFT OUTER JOIN TableB b
       INNER JOIN TableC c
                    ON c.Email = b.email
                    ON a.email = b.email;

I don’t understand why these two SELECT statements produce different results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:38:12+00:00Added an answer on June 10, 2026 at 10:38 pm

    What matters is orders of joins. Treat your expressions as if every join produced temporary “virtual” table.

    So when you write

    FROM TableA a 
    LEFT OUTER JOIN TableB b ON a.email = b.email
    INNER JOIN TableC c ON c.Email = b.email ;
    

    then order is as follows:

    1. TableA is left joined to TableB producing temporary relation V1
    2. V1 is inner joined to TableC.

    Meanhwile when you write:

    FROM TableA a 
    LEFT OUTER JOIN TableB b 
    INNER JOIN TableC c ON c.Email = b.email ON a.email = b.email;
    

    then order is as follows:

    1. TableB is inner joined to TableC producing temporary relation V1.
    2. TableA is left joined to V1.

    Thus results are different. It is generally recommended to use parenthesis in such situations to improve readability of the query:

    FROM TableA a 
    LEFT OUTER JOIN
      (TableB b INNER JOIN TableC c ON c.Email = b.email)
    ON a.email = b.email;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a basic question, but I have been having a hard time
I have been having a really hard time debugging this error since the past
i have been having a hard time to find anything that is usefull but
Ok, I have been having a VERY hard time figuring this out. I guess
I can't believe that this hasn't been covered before, but I have been having
I have been having a hard time understanding how to use a singleton to
So I have been having a hard time sending email from my school's email
I've been having a hard time coming up a solution with this one. I'm
I have been having hard time with Primefaces and SO is my ultimate place
I have been looking at self hosting NuGet, having a hard time understanding how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.