Left Outer Join (Left Join)

Left Outer Join (Left Join)
Download PDF

In SQL, a LEFT OUTER JOIN is a type of JOIN operation that combines data from two tables, based on a JOIN condition. This type of JOIN is called an outer JOIN because it includes not only the matching rows from the tables, but also the rows from the left (or first) table that do not have a matching row in the right (or second) table.

Here is an example of a LEFT OUTER JOIN syntax:

SELECT * FROM table1 LEFT OUTER JOIN table2 ON table1.column1 = table2.column1

In this example, the LEFT OUTER JOIN combines the rows from table1 and table2, based on the JOIN condition table1.column1 = table2.column1. The SELECT statement retrieves all the columns from both tables, so you can see the matching and non-matching rows.

In this example, the LEFT OUTER JOIN includes the rows from table1 that do not have a matching row in table2, and it sets the columns from table2 to NULL for those rows. This allows you to see all the data from the left (or first) table, even if there is no matching data in the right (or second) table.

Want to learn more about join types?

JOIN Types

https://SteveStedman.com/joins

 

More from Stedman Solutions:

SteveStedman5
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!

Leave a Reply

Your email address will not be published. Required fields are marked *

*