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?

Advanced3 Minutes320 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