SQL JOINS are clauses in a SELECT statement that let you query data spread across multiple tables as if it were a single result set. They work by matching rows using an ON or USING condition (or implicitly in a CROSS JOIN). The most common join types are:INNER JOIN – returns only matching rows.LEFT (OUTER) JOIN – returns all rows from the left table plus matching rows from the right.RIGHT (OUTER) JOIN – the mirror of LEFT JOIN.FULL (OUTER) JOIN – returns matches plus non-matching rows from both tables.CROSS JOIN – Cartesian product of both tables (every combination).SELF JOIN – a table joined to itself using table aliases.Joins allow normalization of schemas, reduce data duplication, and enable complex analytics. Performance depends on indexes, join order, and optimizer choices. Watch for NULL handling, duplicate column names, and join conditions that unintentionally create Cartesian products.
join_type
(string) - INNER, LEFT, RIGHT, FULL, CROSSleft_table
(identifier) - first table in the joinright_table
(identifier) - second table in the joinjoin_condition
(expression) - Boolean predicate stated after ON or USINGSELECT, WHERE, GROUP BY, UNION, ON clause, USING clause, subqueries
ANSI SQL-86 (X3.135-1986)
INNER JOIN returns only matching rows; LEFT JOIN returns all rows from the left table plus matches from the right, filling non-matches with NULLs.
Chain multiple JOIN clauses: SELECT ... FROM a JOIN b ON ... JOIN c ON ...; each additional JOIN adds one table to the result set.
Not necessarily. With proper indexes, joins often outperform correlated subqueries because the optimizer can choose efficient join algorithms.
Yes. Use table aliases to distinguish the two logical instances, enabling self joins for hierarchical or comparative analyses.