SQL Joins: Inner, Left and Anti, With Real Output
Three queries asked which customers have no orders; NOT IN returned 0 rows because of one NULL.
Video #122 ยท SQL and analytics
Steps in the video
Files
- joins.py (29 lines)
- run.py (11 lines)
- shop.py (20 lines)
Tested with
Python 3.12.15
What this does not show
The two tables are tiny and made up, and the join rules are quoted from the PostgreSQL docs and checked only in SQLite.
Sources
- https://docs.python.org/3.12/library/sqlite3.html
- https://www.postgresql.org/docs/current/functions-subquery.html
- https://www.postgresql.org/docs/current/queries-table-expressions.html
- https://www.postgresql.org/docs/current/tutorial-join.html
- https://www.sqlite.org/lang_select.html
- https://www.sqlite.org/releaselog/3_39_0.html
Learning IT by Example.