LEFT JOIN in SQL: Complete Guide

In databases, a LEFT JOIN is a type of JOIN operation in an SQL query that selects data from two or more tables.

A LEFT JOIN retrieves all rows from both the left and right tables that meet the join condition. If there are no matching rows in the right table, NULL values are returned.

Here is the grammar.

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

In the aforementioned syntax, table1 is the left table, table2 is the right table, and the ON keyword specifies the join condition. A LEFT JOIN will return all rows from table1, along with any matching rows from table2. If there are no matching rows, NULL values will be returned.

bannerAds