SQL for Beginners: Learn Databases Step by Step

Free SQL course for beginners. 15 lessons in simple English with a practice database: joins, grouping, changing data, window functions and interview questions.

Beginner · 15 lessons

Start Here

  1. What Is SQL and What Is a Database? - Learn what a database is, what SQL does, and why almost every company that stores data uses it. Easy words, no code to install yet.
  2. Set Up a Free Practice Database with SQLite - Install free SQLite tools, create the shop database used in every lesson, and run your first query. Copy-and-paste setup script included.

Reading Data

  1. SELECT, FROM and WHERE: Your First Queries - Write your first real queries: choose columns with SELECT, name the table with FROM, and keep only matching rows with WHERE. Includes NULL.
  2. Filter Rows: AND, OR, IN, BETWEEN and LIKE - Combine conditions with AND and OR, use brackets correctly, and write shorter filters with IN, BETWEEN and LIKE. Real examples and common traps.
  3. Sort and Trim Results: ORDER BY, LIMIT, DISTINCT - Sort rows with ORDER BY, get a top-N list with LIMIT, remove repeats with DISTINCT, and use functions like UPPER, LENGTH, COALESCE and CASE.

Summaries and Groups

  1. Aggregate Functions: COUNT, SUM, AVG, MIN, MAX - Turn many rows into one answer with COUNT, SUM, AVG, MIN and MAX. Learn how NULL changes the result and what COUNT(*) really counts.
  2. GROUP BY and HAVING: Summaries for Each Group - Get one summary row for each category, city or customer with GROUP BY, filter groups with HAVING, and understand WHERE versus HAVING.

Several Tables

  1. Keys and Table Design: Why Data Is Split Into Tables - Understand primary keys, foreign keys and one-to-many relationships, and why good designs split data into several tables. Prepares you for JOIN.
  2. SQL JOINs: INNER JOIN and LEFT JOIN Explained - Combine tables with INNER JOIN and LEFT JOIN. Find customers with no orders, build order totals across three tables, and avoid common join mistakes.
  3. Subqueries, EXISTS and CTEs: Queries Inside Queries - Use a query inside another query with subqueries, EXISTS and WITH (CTEs). Learn the NOT IN with NULL trap and how to split big queries into readable steps.

Changing Data

  1. INSERT, UPDATE and DELETE: Change Data Safely - Add, change and remove rows with INSERT, UPDATE and DELETE. Learn the safe habits that protect real data: SELECT first, always WHERE, and transactions.
  2. CREATE TABLE, Data Types and Constraints - Design your own tables: data types, PRIMARY KEY, NOT NULL, UNIQUE, DEFAULT, CHECK and FOREIGN KEY, plus ALTER TABLE and DROP TABLE.

Going Further

  1. Window Functions: ROW_NUMBER, RANK and Running Totals - Rank rows, find the latest row per customer and calculate running totals with window functions, without collapsing rows like GROUP BY does.
  2. Indexes and Faster Queries: EXPLAIN for Beginners - Learn what an index is, how it speeds up WHERE and JOIN, how to read a query plan with EXPLAIN, and habits that keep queries fast.
  3. SQL Interview Questions and What to Learn Next - Practise the SQL questions that interviewers ask most often, with answers and short explanations, and plan what to learn next after this course.