Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
LEFT OUTER JOIN
On this page

Syntax

Example

Result

A LEFT OUTER JOIN in SQL is a type of join that combines rows from two or more tables based on a specified condition, and includes all rows from the left (or first) table, regardless of whether there is a match in the right (or second) table. If there is no match, NULL values are filled in for columns from the right table.

Syntax

SELECT * FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name;

Example

Consider we have two tables, students and grades, with information about students and their respective grades:

Image

Now, let's perform a LEFT OUTER JOIN to retrieve information about all students and their grades:

MYSQL
MYSQL

. . . .

Result

Image

In this example, the LEFT OUTER JOIN ensures that all students from the students table are included in the result set. The matching rows display the respective grades from the grades table, while the student "David" does not have a corresponding grade, resulting in a NULL value.

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page

Syntax

Example

Result