English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

The usage and example of SQL RIGHT JOIN keyword

SQL Keywords Reference

RIGHT JOIN

The RIGHT JOIN command returns all rows from the right table, along with the matching records from the left table. When there is no match, the result on the left side is NULL.

The following SQL will return all employees and all orders they may have placed:

SELECT Orders.OrderID, Employees.LastName, Employees.FirstName
FROM Orders
RIGHT JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID
ORDER BY Orders.OrderID;

Note:The RIGHT JOIN keyword returns all records from the right table (Employees table) even if there is no match in the left table (Orders table).

SQL Keywords Reference