記錄我有以下查詢工作正常:MySQL查詢使用COUNT()返回其中字段等於COUNT值
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
在該表隊列中,有一個int的列「attendance_pass」。現在我想要有另一個類似於上面的查詢,只返回COUNT(*) FROM attendance
等於cohort.attendance_pass的記錄。例如。
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
如何修改第二個查詢以獲取這些記錄?
非常感謝...這完全符合書面。 – IlludiumPu36