MySQL + SQL · Lesson 66
SQL Join Examples in MySQL
Practical Join Queries
Solved JOIN queries on a school database — common in exams and projects.
List Students with Class Names
SELECT s.name, c.class_name
FROM students s
JOIN classes c ON s.class_id = c.class_id;
Fees Paid by Each Student
SELECT s.name, SUM(f.amount) AS total_paid
FROM students s
JOIN fees f ON s.roll_no = f.roll_no
GROUP BY s.name;
Three-Table Join
SELECT s.name, c.class_name, f.amount
FROM students s
JOIN classes c ON s.class_id = c.class_id
JOIN fees f ON s.roll_no = f.roll_no;You can chain JOINs to combine three or more tables.
Summary
- JOIN + GROUP BY summarises related data (e.g. total fees per student).
- Chain multiple JOINs to combine three or more tables.
💻 Live Code Editor
Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.