SQL Keyword - RIGHT JOIN

RIGHT JOIN Keyword

The RIGHT JOIN keyword is used to combine two tables and returns all records from the right tables and only matching records from the left tables.

Syntax

SELECT * FROM <TABLE1>
RIGHT JOIN <TABLE2> ON <TABLE1>.<COLUMN_NAME>=<TABLE2>.<COLUMN_NAME>

Example

SELECT * FROM Employee
RIGHT JOIN Department ON Employee.Dept_Id = Department.Dept_Id

If there are no matching records in the left tables, only the right table value is displayed, and null values are substituted for the left table value.

Summary

The RIGHT JOIN clause returns a result set that includes all rows from the right tables and only matching rows from the left tables.

Next Recommended Reading SQL Keyword - FULL OUTER JOIN