Left Outer Join SQL

LEFT OUTER JOIN allows reading with table joins that exclude the table
indicated on the left from the intersection conditions.

This article tries to teach you how to apply this statement in SQL read
statements.

For this, you need to have MS SQL Server and SSMS.

Syntax

SELECT columnName(s)
FROM table1
LEFT OUTER JOIN table2
ON table1.columnName=table2.columnName;

Effect

The JOIN syntax is a recursive join expression.

A JOIN expression is made up of a left side and a right side,
joined together using, in this case, LEFT [OUTER] JOIN.

A join expression can be an inner join (INNER) or an outer join (LEFT
OUTER
).

Each join expression can be enclosed in parentheses.

On the left side, you can specify a transparent database table, or a join
expression join.

On the right hand side, a single transparent database table must be
specified, along with the join conditions after ON.

Clustered and pooled tables cannot be joined using join expressions.

As a practical application, the SQL WideWorldImporters Database will be
used.

And the SQL query that applies directly in this case is:

SELECT TOP (15) Purchasing.Suppliers.SupplierName,
Purchasing.SupplierTransactions.PaymentMethodID
FROM Purchasing.Suppliers LEFT OUTER JOIN
Purchasing.SupplierTransactions
ON Purchasing.Suppliers.SupplierID =
Purchasing.SupplierTransactions.SupplierID

Obtaining as a result the following:

You will now see all the rows in the Purchasing.Suppliers table, which is
the table on the left, being displayed as many times as there are matches
on the right side. ‘Nod Publishers’ has not made any transactions, so null
is returned.

Leave a Reply

Your email address will not be published.