SQL LEFT OUTER JOIN

What is SQL LEFT OUTER JOIN

The SQL LEFT OUTER JOIN is the types of the outer join to combine the two tables. It combines the two table but prefer the rows of the first table and add all the rows from the first table to the resulted table.

SQL LEFT OUTER JOIN Image

To get the left join output using SQL, it finds all the rows from the first table including the matching rows from the right table. However, if there is no match in the second table it returns a null value.

How to Use LEFT OUTER JOIN in SQL

To use this types of the outer join of SQL, you have to use the two tables. The first table is the main table from where you have to take all the rows for the matching columns.

Syntax

Now, find all the values of the selected columns in the SQL query. It results out all the matching column rows from the first column and if there is no match with the second column, it returns the null value.

Example of SQL LEFT OUTER JOIN

Let’s create the two tables given below to understand the example of left outer join in SQL server.

Below are the two tables contain the column with one column matching rows.

SQL LEFT OUTER Join Example Using the Select Statement

The first table is Purchaser table and second is the Seller table. The first table contains the list of the purchaser tables
Table 1: Purchaser

Purchaser_IDPurchaser_NamePlot_NoService_Id
1Sam121001
2Pill131002
3Don141003
4Brock151004

The second table is the table contains the list of sellers.
Table 2: Seller

IdSeller_NameSeller_Email
1001Big Show[email protected]
1002Gem[email protected]
1003Matt[email protected]

Now, let’s combine the above two tables using the example given below.

Example

Output

Service_IdSeller_NamePurchaser_NamePlot_No
1001Big ShowSam12
1002GemPill13
1003MattDon14
1004NullBrock15

You must also read.

Reference
Join Syntax

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.