PDQ.com mobilePDQ.com desktop
Support

SQL Right Join

Stephanie WarnerStephanie Warner
·

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:

SQL Set Operators

SQL JOINS

SQL INNER JOIN

SQL LEFT JOIN

SQL UNION vs UNION ALL SQL Full Outer Join

Ready to get started?

Take our 14-day Free Trial.
This round is on us!

Don't miss the next post!

Using PowerShell to Install Printers

When installing printers, we will need to do the four things; Add Driver to the Store, Install the Driver, Create Printer Port, and Install the Printer