SQL Joins study song
Quick answer
A SQL join combines rows from two tables based on a related column, usually a foreign key matched to a primary key. Database exams love to give two small tables and ask how many rows each join type returns, so you need to know exactly what happens to unmatched rows.
Inner joins drop them, outer joins keep them and fill gaps with NULL. A second favourite is the order SQL processes a query, which explains why WHERE cannot use an aggregate but HAVING can. Both topics are short sequences of rules, so a rap with a verse per join type and a chorus for the query order turns them into something you can recite instead of re-derive.
5 facts to know about sql joins
- 1INNER JOIN returns only the rows that have a match in both tables.
- 2LEFT JOIN returns every row from the left table and fills the right table's columns with NULL where there is no match.
- 3FULL OUTER JOIN returns all rows from both tables, with NULL on whichever side has no match.
- 4A CROSS JOIN of tables with m and n rows returns m × n rows.
- 5SQL logically evaluates FROM, WHERE, GROUP BY, HAVING, SELECT, then ORDER BY, so HAVING filters groups after aggregation.














