SQL Fundamentals Tutorial
Learn SQL from scratch: queries, aggregates, joins and safe data changes
Beginner4 lessonsabout 23 min of reading
This course is for people who have never written SQL, as well as developers who copy queries from search results and want to understand them. You need no database installed beyond something that can run SQLite, which ships with Python, and no prior programming experience.
Every statement in the lessons was run against a real SQLite database, and the tables shown are exactly what it returned. Each lesson uses its own small scenario (hiking trails, library loans, podcasts, a seed nursery) so you practise thinking in rows and tables rather than memorising one dataset. Where PostgreSQL, MySQL or SQL Server behave differently, the lesson says so.
The four lessons build in order: reading rows with SELECT, WHERE, ORDER BY and LIMIT; summarising with aggregates, GROUP BY and HAVING; combining tables with JOINs and avoiding the row-multiplication trap; and finally changing data with INSERT, UPDATE and DELETE under the protection of constraints and keys.
SQL Fundamentals lessons
- 1SQL SELECT, WHERE, ORDER BY and LIMIT: Querying Your First TableLearn SQL SELECT with WHERE, ORDER BY and LIMIT on a real table: filter rows, sort results, page through data and avoid the NULL and AND/OR traps.6 min read
- 2SQL GROUP BY, HAVING and Aggregate Functions Explained with ExamplesSummarise rows with SQL aggregate functions, GROUP BY and HAVING. Learn COUNT(*) vs COUNT(column), WHERE vs HAVING, NULL handling and the GROUP BY error.5 min read
- 3SQL JOINs Explained: INNER vs LEFT JOIN and the Row Multiplication TrapSQL JOINs with INNER JOIN and LEFT JOIN on a podcast schema, plus the row-multiplication trap that inflates SUM and COUNT and how to fix it safely.6 min read
- 4SQL INSERT, UPDATE, DELETE, Constraints and Primary and Foreign KeysChange data safely with SQL INSERT, UPDATE and DELETE, and let constraints, primary keys and foreign keys reject bad rows before they reach your tables.6 min read
Preparing for an interview? Practise SQL & Databases interview questions
Learning SQL Fundamentals to land a job? Browse open roles or check which skills are trending.