MySQL5.7 中select student_id from score having num < 60;为什么会报错

新手上路,请多包涵

问题描述

为什么在我想查询成绩(score)表中不及格(num < 60)的学生的ID(student_id),不能使用having select student_id from score having num < 60;只能使用select student_id from score where num < 60;

问题出现的环境背景及自己尝试过哪些方法

mysql5.7

报错信息

clipboard.png

期望

我想知道其中报错的原理

阅读 1.9k
1 个回答

having 是对返回结果进行过滤,返回结果中没有num,你在返回结果中加上num就能过滤了

clipboard.png
正确理解MySQL中的where和having的区别https://blog.csdn.net/yexuden...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题