LogoInterview Master

SQL Learning

SQL LEFT JOIN

LEFT JOIN

Understanding SQL LEFT JOIN

LEFT JOIN retrieves all rows from the left table, and the matching rows from the right table. If there's no match, NULL values will appear for columns from the right table.

Basic Syntax

SELECT columns
FROM table1
LEFT JOIN table2 ON table1.column = table2.column;

Practical Example with TokTuk Dataset

Here's how you might use LEFT JOIN with the TokTuk dataset:

-- Retrieve all users and their videos, including users without videos
SELECT u.username, v.title
FROM Users u
LEFT JOIN Videos v ON u.user_id = v.user_id;

Ready to Practice SQL LEFT JOIN?

Apply your LEFT JOIN skills in our interactive SQL environment.

Loading SQL editor...