In this article, we will learn how to use the LEFT JOIN keyword in SQL.

The LEFT JOIN keyword is used to select all records from the table1 (left table), and the matched records from the table2 (right table). If there is no match, the result from the right side is NULL.

Syntax

SELECT column_name(s)
FROM TABLE_NAME1
LEFT JOIN TABLE_NAME2
ON TABLE_NAME1.column_name = TABLE_NAME2.column_name;

Example

The subsequent statement would select all technologies and any articles if they have. The LEFT JOIN keyword returns all records from the left table (Technology), even if there are no matches in the right table (Article).

SELECT Technology.Name, Article.*
FROM Technology 
LEFT JOIN Article ON Technology.ID = Article.TechID;

 

Also, check How To Use INNER JOIN Keyword In SQL