Examples 291–335 · Part III: Querying
| # | Example | Level |
|---|---|---|
| 291 | Join two tables on a key | Beginner |
| 292 | Join conditions versus WHERE conditions | Beginner |
| 293 | LEFT JOIN keeps unmatched left rows | Beginner |
| 294 | RIGHT JOIN and why LEFT is preferred | Beginner |
| 295 | FULL OUTER JOIN keeps both sides | Beginner |
| 296 | CROSS JOIN produces every combination | Intermediate |
| 297 | Join a table to itself | Intermediate |
| 298 | Join several tables in one query | Intermediate |
| 299 | USING as a shorthand for ON | Intermediate |
| 300 | NATURAL JOIN and why to avoid it | Intermediate |
| 301 | Join on more than one column | Intermediate |
| 302 | Join on an inequality | Intermediate |
| 303 | Join on a date range | Intermediate |
| 304 | LATERAL joins reference the row on the left | Intermediate |
| 305 | LEFT JOIN LATERAL keeps rows with no match | Intermediate |
| 306 | Join to a set-returning function | Intermediate |
| 307 | One-to-many joins multiply rows | Intermediate |
| 308 | Many-to-many needs a bridge table | Intermediate |
| 309 | Attach a child count without fan-out | Intermediate |
| 310 | Two child joins multiply each other | Intermediate |
| 311 | Assert join cardinality | Intermediate |
| 312 | Join produces duplicates, and DISTINCT hides it | Intermediate |
| 313 | A WHERE clause can undo an outer join | Intermediate |
| 314 | Coalesce outer join results | Intermediate |
| 315 | Reconcile two sources with a FULL JOIN | Intermediate |
| 316 | Join, subquery or CTE | Intermediate |
| 317 | Join on a nullable column | Intermediate |
| 318 | Join conditions with OR | Intermediate |
| 319 | Star schema joins | Intermediate |
| 320 | Join to an inline VALUES list | Intermediate |
| 321 | Join with LIMIT: only some rows are needed | Intermediate |
| 322 | Anti-join and semi-join, side by side | Intermediate |
| 323 | Filter a join by an aggregate of the child | Intermediate |
| 324 | Join tables of very different sizes | Intermediate |
| 325 | Walk a fixed-depth hierarchy with self joins | Intermediate |
| 326 | Update and delete using a join | Intermediate |
| 327 | Which join algorithm the planner chose | Advanced |
| 328 | Join order is the planner's decision | Advanced |
| 329 | Many-table joins and the collapse limits | Advanced |
| 330 | Index the join key | Advanced |
| 331 | Read row estimates at a join node | Intermediate |
| 332 | Correlated columns need extended statistics | Intermediate |
| 333 | Join to a lateral aggregate | Intermediate |
| 334 | Diagnose a slow join | Advanced |
| 335 | Choosing a join strategy | Advanced |
The solutions and explanations are in the book.