Never written a line of SQL? Perfect. In a few minutes you’ll understand what a database is, read your first query, and write one yourself — checked live against real data.
A database is just an organized collection of information. Inside it, data lives in tables — which look a lot like spreadsheets. Each table has:
A table — columns across the top, one row per product.
SQL (Structured Query Language) is how you ask questions of that data. You describe what you want in plain, keyword-based sentences and the database returns the matching rows. That’s it.
Almost every query starts with two keywords: SELECT (which columns you want) and FROM (which table). To get everything from a table:
SELECT * FROM products
The * is shorthand for “all columns.” To get just the columns you care about, list them
instead — separated by commas:
SELECT productName, productLine FROM products
Read it like a sentence: “Select the productName and productLine columns from the products table.” SQL is deterministic — the same keywords always mean the same thing, so once you learn a keyword you know it forever.
Add ORDER BY to sort the results by a column. Add DESC for
highest-to-lowest (descending), or leave it off for lowest-to-highest (ascending):
SELECT productName, buyPrice FROM products ORDER BY buyPrice DESC
That asks for product names and their cost, most expensive first. In the Playground, every result also shows the exact SQL it ran and — on the Explain SQL tab — a plain-English breakdown of each keyword.
SELECT columns · FROM a table · ORDER BY to sort · and later WHERE to filter. Master these and you can answer most everyday questions.
Now you try. Write a query in each box and press Check — we’ll verify your SQL and, when it’s right,
run it live against the classicmodels / products table and show you the result.
These exercises use SELECT, FROM and ORDER BY. Capitalization and extra spaces don’t matter.
SQL is a shared language, but every database engine speaks its own dialect — small differences in spelling and features. LearnSQL runs two engines, and the core keywords (SELECT, FROM, WHERE, ORDER BY) are identical in both. Here’s what changes:
| Task | SQL Server (mssql) | MySQL / MariaDB |
|---|---|---|
| Limit the number of rows | SELECT TOP 10 … or OFFSET … FETCH NEXT 10 ROWS ONLY |
… LIMIT 10 |
| Quote a name with spaces | Square brackets: [Order Details] |
Backticks: `Order Details` |
| Join text together | a + b or CONCAT(a, b) |
CONCAT(a, b) |
| Current date/time | GETDATE() |
NOW() |
| Text matching case | Usually case-insensitive | Depends on the column’s collation |
| Where tables live | Inside a schema (here, one named after the database) — so you write db.table |
The database is the namespace — just table |
You rarely need to worry about this at first. The Playground writes the correct dialect for whichever engine you pick, and shows you the exact SQL — so you can see the differences side by side as you learn.
LearnSQL comes with a set of classic sample databases — the same ones used in courses and tutorials worldwide. Each is a small, realistic business. Here’s what they hold: