Mufleeh wrote:Thanks for the response, but can you please tell me what's 'divisions' that you have used here? are referring to a table?
As you can see from the SQL statement, it is an alias for view_zone_division_district_province.
Mufleeh wrote:Also can you please let me know how can I replace me coding with this?
If it works - and I don't know if it works since I typically have to test my SQL statements that involve aggregation to get them right - you will get a result set consisting of division ids and the corresponding counts. You can then loop over it and display. That said, I noticed that I missed a divisions.zone_id='$selectZone' in the WHERE clause.
Actually, if you do not need to display the individual counts of maths teachers in each division, i.e., you only want the total number of maths teachers in the given zone, and assuming that teachers teach in no more than 1 school, the query could become:
SELECT COUNT(*)
FROM view_zone_division_district_province AS divisions
JOIN schools ON divisions.division_id=schools.division_id
JOIN teachers_info ON schools.school_id=teachers_info.school_id
WHERE teachers_info.subject_name = 'Mathematics'
AND divisions.zone_id='$selectZone'