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 7620189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:52:46+00:00 2026-05-31T03:52:46+00:00

Disregarding performance, will I get the same result from query A and B below?

  • 0

Disregarding performance, will I get the same result from query A and B below? How about C and D?

----- Scenario 1: 
-- A (left join)
select *
from   a left join b
           on <blahblah>
       left join c
           on <blahblan>


-- B (left join)
select *
from   a left join c
           on <blahblah>
       left join b
           on <blahblan>  

----- Scenario 2:   
-- C (inner join)
select *
from   a join b
           on <blahblah>
       join c
           on <blahblan>


-- D (inner join)
select *
from   a join c
           on <blahblah>
       join b
           on <blahblan>  
  • 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-05-31T03:52:48+00:00Added an answer on May 31, 2026 at 3:52 am

    For INNER joins, no, the order doesn’t matter. The queries will return same results, as long as you change your selects from SELECT * to SELECT a.*, b.*, c.*.


    For (LEFT, RIGHT or FULL) OUTER joins, yes, the order matters – and (updated) things are much more complicated.

    First, outer joins are not commutative, so a LEFT JOIN b is not the same as b LEFT JOIN a

    Outer joins are not associative either, so in your examples which involve both (commutativity and associativity) properties:

    a LEFT JOIN b 
        ON b.ab_id = a.ab_id
      LEFT JOIN c
        ON c.ac_id = a.ac_id
    

    is equivalent to:

    a LEFT JOIN c 
        ON c.ac_id = a.ac_id
      LEFT JOIN b
        ON b.ab_id = a.ab_id
    

    but:

    a LEFT JOIN b 
        ON  b.ab_id = a.ab_id
      LEFT JOIN c
        ON  c.ac_id = a.ac_id
        AND c.bc_id = b.bc_id
    

    is not equivalent to:

    a LEFT JOIN c 
        ON  c.ac_id = a.ac_id
      LEFT JOIN b
        ON  b.ab_id = a.ab_id
        AND b.bc_id = c.bc_id
    

    Another (hopefully simpler) associativity example. Think of this as (a LEFT JOIN b) LEFT JOIN c:

    a LEFT JOIN b 
        ON b.ab_id = a.ab_id          -- AB condition
     LEFT JOIN c
        ON c.bc_id = b.bc_id          -- BC condition
    

    This is equivalent to a LEFT JOIN (b LEFT JOIN c):

    a LEFT JOIN  
        b LEFT JOIN c
            ON c.bc_id = b.bc_id          -- BC condition
        ON b.ab_id = a.ab_id          -- AB condition
    

    only because we have “nice” ON conditions. Both ON b.ab_id = a.ab_id and c.bc_id = b.bc_id are equality checks and do not involve NULL comparisons.

    You can even have conditions with other operators or more complex ones like: ON a.x <= b.x or ON a.x = 7 or ON a.x LIKE b.x or ON (a.x, a.y) = (b.x, b.y) and the two queries would still be equivalent.

    If however, any of these involved IS NULL or a function that is related to nulls like COALESCE(), for example if the condition was b.ab_id IS NULL, then the two queries would not be equivalent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I create a query/vba function similar to DateDiff that splits the result
Disregarding my question I asked earlier (and deleted) which has been solved, I want
I think we've all heard about different IE rendering modes, mostly based on their
In an JS app, I receive timestamp (eq. 1270544790922 ) from server (Ajax). Basing
Disregarding my last post, I've found the source of the problem. I'm using a.renameTo(b)
I want to be able to compare two doubles disregarding a possible precision loss.
I'm trying to float a large left curly quote so that the blockquote sits
I have a table of transactions which will occasionally have duplicate entries. If/When an
After reading The JSR-133 Cookbook for Compiler Writers about the implementation of volatile, especially
I am using vim to make a simple script trying get the output of

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.