SQL for an 11-year-old — Easy Step-by-Step
SQL (said "ess-que-el" or "sequel") is a language used to talk to databases. A database stores information. SQL helps you read, add, change, and remove that information.
Imagine this:
Think of a database table like a school class list on paper (or a spreadsheet). Each row is a student. Each column is a detail about that student, like name or age.
Example table: Students
| id | name | age | grade | favorite_subject |
|---|---|---|---|---|
| 1 | Ana | 11 | 5 | Math |
| 2 | Ben | 12 | 6 | Art |
| 3 | Carlos | 11 | 5 | History |
Basic SQL commands
We'll look at four common actions: SELECT (read), INSERT (add), UPDATE (change), and DELETE (remove).
1) SELECT — read data
Get everything about all students:
SELECT * FROM Students;
Get only names and ages:
SELECT name, age FROM Students;
Get only students older than 11:
SELECT * FROM Students WHERE age > 11;
Get students sorted by age (oldest first):
SELECT * FROM Students ORDER BY age DESC;
2) INSERT — add a new row
Add a new student named Maya:
INSERT INTO Students (id, name, age, grade, favorite_subject)
VALUES (4, 'Maya', 11, 6, 'Science');
3) UPDATE — change existing data
Change Maya's favorite subject to Math:
UPDATE Students
SET favorite_subject = 'Math'
WHERE name = 'Maya';
4) DELETE — remove a row
Remove the student with id 4 (Maya):
DELETE FROM Students WHERE id = 4;
What the parts mean (step-by-step)
- SELECT — which columns you want to see (like name or age). "*" means all columns.
- FROM — which table (our table is Students).
- WHERE — only pick rows that meet a condition (like age > 11).
- ORDER BY — put the results in order, ASC (small to big) or DESC (big to small).
- INSERT INTO ... VALUES(...) — add a new row with the values you give.
- UPDATE ... SET ... WHERE ... — change one or more columns for rows that match the WHERE rule.
- DELETE FROM ... WHERE ... — remove rows that match the WHERE rule.
Important tip: use a unique id
Each row usually has an id number that is different for every row. That helps to change or delete the exact row you want without mistakes.
Quick practice (try these)
- Write a query to get the names of all students in grade 5.
- Write a query to find students whose favorite subject is 'Art'.
- Write a query to change Ben's favorite subject to 'Music'.
Answers
SELECT name FROM Students WHERE grade = 5;SELECT * FROM Students WHERE favorite_subject = 'Art';UPDATE Students SET favorite_subject = 'Music' WHERE name = 'Ben';
Final encouragement
SQL is like asking questions to a very organized friend who keeps lists. Start with SELECT queries to read data, then try INSERT and UPDATE when you want to change things. Practice on small example tables (like the Students table) and you'll get better fast!
If you want, I can give you an interactive practice set or make more beginner exercises with answers.