Learn SQL from zero
Twelve short lessons that take you from “what is a database” to joins and normalisation. Each lesson has examples you run with one click and exercises the site grades instantly.
Lessons
What is a database?
Tables, rows, columns and keys.
SELECT: choosing columns
Show only the columns you need, aliases and DISTINCT.
WHERE: filtering rows
Comparisons, AND/OR, IN, BETWEEN and LIKE.
ORDER BY & LIMIT: sorting
Sort results up or down and keep the first N rows.
Aggregate functions
COUNT, SUM, AVG, MIN and MAX.
GROUP BY & HAVING
Aggregate per group and filter groups.
Joining tables: INNER JOIN
Combine data from several tables through keys.
LEFT JOIN and join types
Keep rows without matches, and self-joins.
Subqueries
A query inside a query.
Creating tables and constraints
CREATE TABLE, data types and keys.
INSERT, UPDATE and DELETE
Adding, changing and removing data.
Relationships and normalisation
1:1, 1:N, M:N, and why we split tables.
The practice database
A small company selling hardware and software to clients across the Gulf and the Arab world: departments, employees, customers, products, orders and order lines. It is normalised so you can practise joins like on real systems.
- dept_idPK
- name
- city
- emp_idPK
- first_name
- last_name
- dept_id→ departmentsFK
- job_title
- salary
- hire_date
- manager_id→ employeesFK
- customer_idPK
- name
- city
- country
- signup_date
- product_idPK
- name
- category
- price
- stock
- order_idPK
- customer_id→ customersFK
- emp_id→ employeesFK
- order_date
- status
- order_id→ ordersPK FK
- product_id→ productsPK FK
- quantity
- unit_price