I have the following query which works fine:
SELECT *, COUNT(*) FROM attendance, cohort
WHERE
attendance.cohort_fk = cohort.cohort_pk
AND
attendance.cohort_fk = '$cohort'
AND
YEAR(attendance.attended) = '$year'
GROUP BY attendance.person_id ASC
In the table cohort, there is an int column 'attendance_pass'. Now I want to have another query similar to above that only returns records where COUNT(*) FROM attendance equals cohort.attendance_pass. Eg.
SELECT *, COUNT(*) FROM attendance, cohort
WHERE
attendance.cohort_fk = cohort.cohort_pk
AND
attendance.cohort_fk = '$cohort'
AND
YEAR(attendance.attended) = '$year'
AND
COUNT() = cohort.attendance_pass
GROUP BY attendance.person_id ASC
How can I modify this second query to get just those records?