mysql中出現 Unknown column ‘xxx‘ in ‘having clause‘
這是因為在使用group by分組時,后面如果需要再加一個having進行判斷,則所判斷的字段需要在select后面出現
如:
select c.studentNo, c.name, count(coursename) from courses a, scores b, students c where a.courseNo = b.courseNo and b.studentNo = c.studentNo GROUP BY c.studentNo having count(coursename) = 5
如果不出現,則會報錯
*代碼只是做演示,結果是有問題的