I have 2 tables for students and courses. The first contains student names who are each in a course and the second contains the courses and each course has a checkbox associated with it.
My question is, how do I display the number of students that are in a each course that is checked?
Example:
I am new to programming, so I appreciate any help you can give me. :D
select c.*, count(sc.student_id) as total
from students_courses sc
left join courses c on c.id = sc.course_id
group by c.id
Here I assume that you have 3 tables.
courses (id, name, status)
students(id, name, email, ...)
students_courses (id, course_id, student_id)