INNER JOIN
Join two tables with matching keys; basic patterns.
What you’ll learn
- Join two tables on a key; select columns from both sides.
SELECT o.OrderID, o.OrderDate, c.CustomerID, c.Name
FROM dbo.Orders AS o
JOIN dbo.Customers AS c
ON c.CustomerID = o.CustomerID;
Notes
- Join predicates belong in
ON
, notWHERE
(esp. with OUTER joins). - Add selective predicates to help the optimizer choose a seek.