Learn SQL byplaying

Short levels in a little game shop. You write real SQL, a real database answers, and every answer is checked by its result.

byte-shop.db3 tables
The Byte Shop database: customers, products and orders, linked by their keys
XP
0
Levels done
0/41
Stars
0/123
Up next
Look at the Shelf
Level 1.01 · First Queries

Your path through SQL

4 stages · 18 levels

Your first queries: read a table, filter and sort rows, then change data and build a table.

Stars: 3 without an error, 2 with up to two, 1 with more.

  1. Stage 1: First Queries

    Ask the database for data: whole tables, single columns, calculated values.

    0/4

  2. Stage 2: Filtering

    Keep only the rows you need with WHERE: comparisons, AND and OR, lists, patterns and missing values.

    0/6

  3. Stage 3: Sorting and Limiting

    Put rows in order with ORDER BY and keep just the first few with LIMIT.

    0/4

  4. Stage 4: Changing Data

    Add, change and remove rows, then build a table of your own.

    0/4

What makes it different

01SQLite · WebAssembly

A real database

SQLite runs inside your browser, the same engine that sits in every phone. Error messages are the real ones.

SELECT nme FROM products;

no such column: nme

022 queries · 1 result

Checked by result

There is more than one right query. Yours counts if it returns the right rows, however you wrote it.

  • SELECT name FROM products WHERE price < 20;
    passes
  • SELECT name FROM products WHERE NOT price >= 20;
    passes
nametext
Memory Card
Space Lords
Pixel Puzzle

Same rows, so both count.

03visible + hidden data

No lucky guesses

Every answer is also checked against data you cannot see, so a query that only fits the rows on screen does not pass.

Task: list the products that are sold out.

SELECT name FROM products WHERE id IN (3, 5, 8);
Data you seepasses
nametext
Arcade Stick
Pocket Glow
Space Lords
Hidden datafails
nametext
Handheld Pro
Link Cable
Home Console X

Your first query takes ten seconds.

Write it now