RIGHT JOIN (or RIGHT OUTER JOIN) renders ALL records from the table on the right side (Table 2) and corresponding records of the table on the left side (Table 1). In a RIGHT JOIN, records that do not have corresponding data from the left table will show ‘NULL’ values from columns/fields selected from the left table.

NOTE: RIGHT JOIN is very similar to LEFT JOIN. The difference has to do with the table positioning in relation to the query. The ‘left’ table is always the table referred to in the FROM clause. The ‘right’ table is the table used after the JOIN clause and the matching column in each table is what binds the tables together.
RIGHT JOIN Syntax:
SELECT table_1.field1, table_1.field2, table_2.field1, table_2.fieldn....
FROM Table_1
RIGHT JOIN table_2
ON table_1.matching_field = table2.matching_field;
RIGHT JOIN Example:
Table 1


Table 2


RIGHT JOIN Query:


Notice how the result set only outputs three rows. There are only three rows because the use case only applies to three customer results from the ‘Customers’ table.
This blog post is part of our SQL series:

Stephanie is a big time math nerd, avid snowboarder, and overall winter lover. She enjoys the torture of running and traveling to work Ragnar Relay races. From shredding the gnar to getting far too invested in murder/crime documentaries, you'll also find her petting all the doggos. She was an employee of PDQ.
Related articles