SQLMentor // glossary

SQL JOIN

A JOIN combines rows from two or more tables based on a related column. It is how you assemble a complete result from data that normalization split across tables.

The main types are INNER JOIN (only matching rows), LEFT/RIGHT JOIN (all rows from one side plus matches), and FULL OUTER JOIN (all rows from both). The ON clause states how the tables relate — usually a foreign key matching a primary key.

Joining on a NULL value never matches (NULL equals nothing), which is why unmatched rows disappear in an inner join but survive, NULL-filled, in an outer join.

Example

SELECT e.first_name, d.department_name
FROM   employees   e
JOIN   departments d ON e.department_id = d.department_id;