+ Reply to Thread
Results 1 to 5 of 5

Left join vs Right join

  1. #1
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Left join vs Right join

    Ok, so I'm starting to get the hang of basic inner joins, still confused on Left and Right though. I know the end result of each but I am a little confused on the syntax;

    This is regarding Microsoft SQL

    so, if I use a regular join;

    Please Login or Register  to view this content.

    Easy enough

    Return results where there is a match on both sides, full join


    But for Left/Right joins, I know it is to return all values from either the Left or Right, as in all results from Table1, return NULLS if no match in Table2, but where does left/right come into play?

    Which one of these, if any is correct?

    Color code; when using
    LEFT
    RIGHT


    is it reading the code as;
    Table1 JOIN Table2 on Table1.Field1 = Table2.Field1
    or
    Table1 JOIN Table2 on Table1.Field1 = Table2.Field1
    or
    Table1 JOIN Table2 on Table1.Field1 = Table2.Field1

    Does this make sense?
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Left join vs Right join

    Ok, for starters, don't just use Join, use the full syntax, so use INNER JOIN rather than just JOIN

    AS for Left join and Right Join, the left refers to the table/View/Function to the left of the LEFT JOIN, so it will return all rows from the table to the left:

    FROM
    Table1(All these rows are returned) LEFT JOIN XXX (Only matching rows are returned) on Table1.xyz on XXX.xyz

    Right Join is the opposite

    FROM
    XXX (only matching rows) RIGHT JOIN Table1(All these rows are returned) on Table1.xyz on XXX.xyz

    Make sense?

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Left join vs Right join

    Got it, so the LEFT/RIGHT qualifier is referring to the table listed Left/Right of the word JOIN as in my first of three possibilities, not the ON or the ='s listed in the other two. That answers my question, thanks!

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Left join vs Right join

    Yup, that's it

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Left join vs Right join

    An example of these Joins will be like this.....

    Left Join:
    Please Login or Register  to view this content.
    This will return all the rows from the left table(Employees) even if there are no matches in the right table (Orders).

    Right Join:
    Please Login or Register  to view this content.
    This will return all the rows from the right table (Empoyees) even if there are no matches in the left table (Orders).
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] SQL Join - Left Join, but with 4 tables
    By kenny.fsw in forum Access Tables & Databases
    Replies: 4
    Last Post: 05-29-2013, 09:03 AM
  2. PowerPivot with Left Join
    By frage2010 in forum Excel General
    Replies: 0
    Last Post: 03-16-2012, 04:06 AM
  3. [SOLVED] Subquery after Left Join
    By Pontificateur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-19-2006, 10:55 AM
  4. LEFT JOIN sql query
    By Michael Malinsky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2005, 04:05 PM
  5. [SOLVED] ADO Recordset Problem -- Left Join
    By ExcelMan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-24-2005, 06:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1