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

  • Home
  • SEARCH
  • 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 6925973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:51:31+00:00 2026-05-27T10:51:31+00:00

At times, the following statement is confusing, at least to me, though I have

  • 0

At times, the following statement is confusing, at least to me, though I have been working with joins for a long time.

The part which is confusing here is, considering second left join

SELECT * FROM table1  
    LEFT JOIN table2 ON table1.id=table2.id  
    LEFT JOIN table3 ON table2.id=table3.id;
  1. Which will be considered as left table – either table1 or table2 (table2 is involved in join condition).

  2. If I recall correctly, left join result involves matched results from join condition and unmatched results from left table. If left table is table1 (from point 1.), what will be unmatched rows from table1, as it isn’t involved in the join condition.

  • 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-27T10:51:32+00:00Added an answer on May 27, 2026 at 10:51 am

    The query will return all of the rows that are in Table1. It will join the rows from Table2 only where the id values are equal between Table1 and Table2. It will also join the rows from Table3 where the id values are equal between the result of the join of (Table1 AND Table2) and Table3. So if the first join between Table1 and Table2 has produced a NULL result (no equivalent id value in Table2), then the second join will also produce a NULL result. For example (using SQL Server):

    DECLARE @Table1 TABLE([ID] INT, [Value] VARCHAR(20))
    INSERT INTO @Table1 VALUES(1, 'Table 1 ID 1')
    INSERT INTO @Table1 VALUES(2, 'Table 1 ID 2')
    INSERT INTO @Table1 VALUES(3, 'Table 1 ID 3')
    
    DECLARE @Table2 TABLE([ID] INT, [Value] VARCHAR(20))
    INSERT INTO @Table2 VALUES(1, 'Table 2 ID 1')
    INSERT INTO @Table2 VALUES(3, 'Table 2 ID 3')
    INSERT INTO @Table2 VALUES(5, 'Table 2 ID 5')
    
    DECLARE @Table3 TABLE([ID] INT, [Value] VARCHAR(20))
    INSERT INTO @Table3 VALUES(2, 'Table 3 ID 2')
    INSERT INTO @Table3 VALUES(3, 'Table 3 ID 3')
    INSERT INTO @Table3 VALUES(5, 'Table 3 ID 5')
    
    SELECT * 
    FROM @Table1 T1
    LEFT JOIN @Table2 T2 ON T1.ID = T2.ID
    LEFT JOIN @Table3 T3 ON T2.ID = T3.ID
    

    This query will produce the following results:

    ID  Value          ID   Value           ID    Value
    -----------------------------------------------------------
    1   Table 1 ID 1   1    Table 2 ID 1    NULL  NULL
    2   Table 1 ID 2   NULL NULL            NULL  NULL
    3   Table 1 ID 3   3    Table 2 ID 3    3     Table 3 ID 3
    

    To answer your question, Table1 is involved on the second join because the second join will only contain rows from Table2 that were able to be joined with Table1. In other words, the second join isn’t Table2 to Table3, it’s the result of the left join of Table1 and Table2 to Table3. So in my example, even though Table2 and Table3 both have records with an ID of 5, those records are not included in the result set because Table1 does not have a record with an ID of 5.

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

Sidebar

Related Questions

I have used the following statements to get the current time. print $query executed
The following is not working because @only is undefined (stated 30 times in the
I have the following string repeated many times (about 10 times) <br /> <a
I have read the following statement regarding to the comparison of C# value types
I have the following statement SELECT disease.id, disease.name, disease_synonym.name FROM disease JOIN disease_synonym where
I have a little problem, have the following statement in mysql: SELECT cmfilm.*, cmgenre.titel
How can I update 2 columns at a time? I tried the following statement,
In the following code I have to reuse the Active Pattern result three times
I am solving following problem - I have on my page statement of items
Assume following code, NSString *str=[[NSString alloc] initWithString:@sagar]; [str autorelease]; I have seen many times

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.