Skip to main content
SQL โ€ข LESSON 19

SQL RIGHT JOIN

How do we retain all records from the right table while matching optional left table data?

Advancedโฑ 3 Minutesโญ 320 XP
๐Ÿค” THE QUESTION

How do we retain all records from the right table while matching optional left table data?

๐Ÿ’ก WHAT IS IT?

RIGHT JOIN returns all records from the right table and matched values from the left table.

๐ŸŽฏ WHAT IS IT USED FOR?

Auditing departments with no assigned employees, empty catalog categories, unused promo codes.

๐Ÿ’ป EXAMPLE
SELECT employees.name,
departments.department_name
FROM employees
RIGHT JOIN departments
ON employees.department_id = departments.id;

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for SQL RIGHT JOIN.

  • โœ“ RIGHT JOIN
  • โœ“ Right table preservation
  • โœ“ ON condition
  • โœ“ Relational audit