SQL Basic explicit inner join

Download SQL for free

Example

A basic join (also called "inner join") queries data from two tables, with their relationship defined in a join clause.

The following example will select employees' first names (FName) from the Employees table and the name of the department they work for (Name) from the Departments table:

SELECT Employees.FName, Departments.Name
FROM   Employees
JOIN   Departments
ON Employees.DepartmentId = Departments.Id

This would return the following from the example database:

Employees.FNameDepartments.Name
JamesHR
JohnHR
RichardSales
CROSS APPLY & LATERAL JOIN