LEFT JOIN, RIGHT JOIN Operations Examples

 

SQL statement

Description

 

SELECT [Department Name],
[First Name] & " " & [Last Name] AS Name
FROM Departments, Employees,
Departments LEFT JOIN Employees
ON Departments.[Department ID] = Employees.[Department ID]
ORDER BY [Department Name]

Selects all departments, including those without employees

SELECT [Last Name] & ", " & [First Name]
AS Name, [Department Name]
FROM Departments, Employees,
Departments RIGHT JOIN Employees
ON Departments.[Department ID] = Employees.[Department ID]
ORDER BY [Last Name] & ", " & [First Name]

Selects all employees, including those not assigned to a department