Join Operators

Joins are used to query two or more tables based on the relationship between columns in these tables.

Many common joins are between two tables related by a key. The most common join restricts foreign key values in one table to be equal to primary key values in another table. The example you have already seen restricts foreign key values in the SalesOrders table to be equal to the candidate key values in the Employees table.

SELECT Surname, 
  EmployeeID, 
  OrderDate 
FROM SalesOrders, Employees
WHERE SalesOrders.SalesRepresentative = Employees.EmployeeID

The query can be more simply expressed using a KEY JOIN, as described in the following section.