#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 9
4 min read

RIGHT JOIN

Keep ALL records from the right table - opposite of LEFT JOIN.

What is RIGHT JOIN?

RIGHT JOIN shows ALL rows from the right table, even if no match exists in the left table.

Simple rule: Right table = Always shown, Left table = Only if match

How RIGHT JOIN Works

Basic Syntax

SELECT columns FROM left_table RIGHT JOIN right_table ON left_table.id = right_table.foreign_id;

Example: All Orders with Students

SELECT students.name, orders.product FROM students RIGHT JOIN orders ON students.id = orders.student_id;

Result: All orders shown, even if student doesn't exist (NULL for name)

RIGHT JOIN vs LEFT JOIN

  • LEFT JOIN → All from LEFT table
  • RIGHT JOIN → All from RIGHT table

Tip: RIGHT JOIN is rarely used. Just swap tables and use LEFT JOIN!

Try It Below

Practice with pre-joined RIGHT JOIN results!

What Comes Next

Next: FULL OUTER JOIN - shows ALL from both tables.

Finished this topic?

Mark it complete to track your progress and maintain your streak!