SQL Server Interview Question #61

What is a JOIN in SQL Server?

Joins, Subqueries, CTEs & Set Operators Mid-Level Intermediate

Detailed Explanation

A JOIN combines rows from two or more data sources based on a relationship between them. Joins are fundamental in relational databases because normalized data is usually distributed across multiple related tables.

The most common join types are INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, and CROSS JOIN. The join condition is normally written in the ON clause.

Code Example

SELECT p.Id, p.Name, c.Name AS CategoryName
FROM dbo.Products AS p
INNER JOIN dbo.Categories AS c
    ON c.Id = p.CategoryId;