How I'd explain SQL to a 5-year-old.
A class register is a table. Raising hands is WHERE. Matching tiffin boxes to kids is a JOIN.
If SQL still feels scary, read this once. Then send it to the friend who keeps saying SQL is hard.
Save it for your next revision.
Ideas 1-6
The basics, in class.
Table
Your class register. Each row is one student. Each column is one detail: name, roll no, marks.
FROM studentsSELECT
Teacher says: show me only the names and marks. Nothing else.
SELECT name, marksWHERE
Only kids who scored above 80, raise your hands!
WHERE marks > 80ORDER BY
Line up from shortest to tallest. Same kids, new order.
ORDER BY heightGROUP BY
Put the toys in boxes by colour. Then look at each box.
GROUP BY colourCOUNT
How many kids came to school today? Count the ticks.
COUNT(*)Ideas 7-12
Lunch break, the tricky bits.
SUM / AVG
Add up everyone's pocket money. Then share it equally. That's the average.
SUM(money), AVG(money)JOIN
Match each tiffin box to its kid using the name tag.
JOIN tiffins ON nameLEFT JOIN
Every kid comes to lunch, even the one whose tiffin is missing. He gets an empty plate.
LEFT JOIN tiffinsDISTINCT
Say everyone's favourite ice-cream flavour, but each flavour only once.
SELECT DISTINCT flavourLIMIT
Only the first 3 kids in line get the swing.
LIMIT 3NULL
The answer box is empty. Not zero. Nobody knows yet.
WHERE marks IS NULL