SQL Learning
SQL RIGHT JOIN
SQL Learning
SQL RIGHT JOIN
Learn how to use RIGHT JOIN to retrieve all rows from the right table and matching rows from the left table
Understanding SQL RIGHT JOIN
RIGHT JOIN retrieves all rows from the right table and the matching rows from the left table. Rows from the left table without a match appear with NULL values for the left table columns.
Basic Syntax
SELECT columns
FROM table1
RIGHT JOIN table2 ON table1.column = table2.column;
Practical Example with TokTuk Dataset
Here's a practical RIGHT JOIN example using the TokTuk dataset:
-- Retrieve all videos and their interactions, including videos without interactions
SELECT v.title, i.interaction_type
FROM Interactions i
RIGHT JOIN Videos v ON i.video_id = v.video_id;
Ready to Practice SQL RIGHT JOIN?
Hone your RIGHT JOIN skills in our interactive SQL environment.