LEFT JOIN vs. LEFT OUTER JOIN in SQL Server

后端 未结 12 1678
失恋的感觉
失恋的感觉 2020-11-21 13:25

What is the difference between LEFT JOIN and LEFT OUTER JOIN?

12条回答
  •  爱一瞬间的悲伤
    2020-11-21 13:41

    To answer your question there is no difference between LEFT JOIN and LEFT OUTER JOIN, they are exactly same that said...

    At the top level there are mainly 3 types of joins:

    1. INNER
    2. OUTER
    3. CROSS

    1. INNER JOIN - fetches data if present in both the tables.

    2. OUTER JOIN are of 3 types:

      1. LEFT OUTER JOIN - fetches data if present in the left table.
      2. RIGHT OUTER JOIN - fetches data if present in the right table.
      3. FULL OUTER JOIN - fetches data if present in either of the two tables.
    3. CROSS JOIN, as the name suggests, does [n X m] that joins everything to everything.
      Similar to scenario where we simply lists the tables for joining (in the FROM clause of the SELECT statement), using commas to separate them.


    Points to be noted:

    • If you just mention JOIN then by default it is a INNER JOIN.
    • An OUTER join has to be LEFT | RIGHT | FULL you can not simply say OUTER JOIN.
    • You can drop OUTER keyword and just say LEFT JOIN or RIGHT JOIN or FULL JOIN.

    For those who want to visualise these in a better way, please go to this link: A Visual Explanation of SQL Joins

提交回复
热议问题