[Solved] Fetch teacher and subject wise details in mysql and php


Why don’t you combine both into a single SQL?

SQL query to fetch the details of each teacher in a searched institute
and their subject strength where institute is equal to searched
institue.

Show only that teacher details which is not having strength of 25
students in each subject where institue is equal to searched
institute.


select name, subject, count(students) as Student_count
from tution 
where institute="$search_institute"
group by name, subject
having count(students) != 25

the group by allows for aggregation of data across columns. Here, you’re grouping the result set by Name & their subject along with the count. The where clause filters out the result to provide only those institutes matching '$search_institute' and the having clause filters our groups not having student count of 25

3

solved Fetch teacher and subject wise details in mysql and php