Platform / Lessons / SQL Programming
SQL Programming

Let's make sense of SQL.

The language databases actually speak. Create a database, build a table, drop in some rows, then ask it questions — one interactive slide at a time.

01

What you'll learn

This is the full written version of an interactive, slide-by-slide lesson deck used in teaching. Everything covered in the deck is below — open the interactive version to work through it with live diagrams, worked examples and a practice quiz where included.

02

Lesson contents

  1. The Language
  2. Building Blocks
  3. Command 1 of 5
  4. Command 2 of 5
  5. Command 3 of 5
  6. Filtering with WHERE
  7. Sorting with ORDER BY
  8. Command 4 of 5
  9. Command 5 of 5
  10. Going Further
  11. Joining Tables
  12. Quick Reference

The Language

SQL is not case-sensitive — SELECT = select = Select. But writing keywords in UPPERCASE is standard practice.

Building Blocks

Every column in a table must have a data type — it tells MySQL what kind of value to expect.

Command 1 of 5

Command 2 of 5

💡 You must supply a value for id — it is the PRIMARY KEY and must be unique for every row.

Command 3 of 5

Filtering with WHERE

💡 Use LIKE '%term%' to search text — e.g. WHERE name LIKE 'A%' finds all names starting with A.

Sorting with ORDER BY

💡 Add LIMIT 10 at the end to get only the top N results — great for leaderboards!

Command 4 of 5

Command 5 of 5

Going Further

Joining Tables

Quick Reference

Common questions

What is the difference between CREATE DATABASE and CREATE TABLE?

CREATE DATABASE makes an empty container to hold tables. CREATE TABLE defines the actual structure — the columns, their data types, and the constraints — inside that container. You run CREATE DATABASE once, then CREATE TABLE for each table you need.

What order do the parts of a SELECT statement go in?

SELECT columns, FROM table, WHERE row conditions, GROUP BY grouping, HAVING conditions on groups, then ORDER BY sorting. The database does not execute them in that order — FROM and WHERE run before SELECT — which is why you cannot use a column alias defined in SELECT inside a WHERE clause.

Related lessons

Work through it interactively

The interactive deck adds live diagrams, step-by-step reveals and practice activities that this written version can't carry.