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
如果不出现,则会报错
*代码只是做演示,结果是有问题的