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.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

WhatsApp