SQL Course: Start Here
No experience needed. What a database is, what SQL does, the shop database you will practise on, how each lesson works, and your very first queries.
What is a database?
A database is an organised collection of data that many people and programs can use at the same time. Your bank balance, your online orders, your university enrolment and every app on your phone keep their data in databases.
Most business data lives in relational databases, which store data in tables. A table looks like a spreadsheet: each row is one thing (one customer, one order) and each column is one fact about it (name, city, date). Unlike a spreadsheet, every value in a column has the same type, and tables are linked to each other by keys.
SQL (Structured Query Language, said "S-Q-L" or "sequel") is the language for asking a database questions and changing its data. You describe what you want, and the database works out how to get it:
That reads almost like English: "give me the name and city of the customers whose country is Australia".
Why learn SQL?
- It is everywhere. SQL has been the standard for 50 years and is used by nearly every company. Data analysts, data scientists, software engineers and AI engineers all use it, usually every day.
- It is the first step of every data project. Before you can analyse data or train a model, you have to get the data out of a database, and that means SQL.
- It is small. A dozen keywords cover most real work. You can be useful after a few weeks.
- Interviews test it. SQL questions are part of almost every data and analyst job interview.
The shop database you will use
Every lesson uses the same small database of an online shop, running right inside this page. It has four tables, linked by keys:
| Table | Columns | Rows |
|---|---|---|
| customers | customer_id (key), name, city (two are NULL), country, joined | 20 |
| products | product_id (key), name, category, price | 15 |
| orders | order_id (key), customer_id โ customers, order_date, status | about 60 |
| order_items | order_id โ orders, product_id โ products, quantity, unit_price | about 150 |
An arrow (โ) means the column holds a key from another table: orders.customer_id says which customer placed the order. A few things are deliberately untidy, like real data: two customers have no city (NULL), some customers have never ordered, and some orders were cancelled.
Try it: your first queries
This is a real SQLite database in your browser. Press a preset, then โถ Run. Then change something (a column name, a number) and run it again. You cannot break anything: Reset brings back the original data.
Interactive: this part runs in your browser.
How each lesson works
- Read the idea in plain words, or press play at the bottom of the page to listen.
- Run the examples in the "Try it" boxes and change them.
- Practise. Each lesson ends with exercises: write a query, press โ Check my answer, and the page runs your query and compares the result with the correct one, telling you exactly what differs (missing rows, wrong columns, wrong order).
- Quiz to make sure the ideas stuck.
For more practice, there are SQL practice problems from easy to interview level, an SQL reference with every keyword and function, and the SQL playground with bigger databases. The next lesson shows how to set up SQL on your own computer.
SQL dialects
There are many database systems: SQLite (inside phones, browsers and this page), PostgreSQL (the most popular open-source server), MySQL, Microsoft SQL Server, Oracle, and cloud warehouses like BigQuery and Snowflake. They all speak SQL, with small differences ("dialects"), mostly in date and text functions. About 90% of what you learn here works everywhere; where a difference matters, the lesson says so.
Practice: check yourself
Write the query, then press โ Check my answer: your query runs on a fresh copy of the shop database and its result is compared with the correct one. โถ Run just shows your result. Each run starts from the original data, so you cannot break anything.
Tables: customers(customer_id, name, city, country, joined) ยท products(product_id, name, category, price) ยท orders(order_id, customer_id, order_date, status) ยท order_items(order_id, product_id, quantity, unit_price)
Show every column of every row in the products table.
Show just the name and country of every customer.
Quiz
1. In a table, what is a row?
2. What does orders.customer_id hold?
3. Which statement about SQL is true?
๐ Further reading
Trusted, mostly free sources: official documentation, well-known textbooks and courses. When you want to confirm or go deeper on anything here, start with these.
- SQLBolt โ free interactive SQL lessons in the browser
- PostgreSQL Tutorial (official documentation) โ SQL concepts, joins, aggregates, transactions and window functions