Mysql中关于group by having的报错,好多人应该没遇到过

这是由于分组后Cno字段存在多个值而无法进行准确判断吗?
应该怎么用having筛选出Cno不等于1的Sno
求指导!

十分感谢

img

img

having是对分组后的结果进行过滤,你并没有查询出Cno字段。
条件可以直接放在where后面,不用放在having中。

select sc.Sno from sc where sc.Cno<>'1' group by sc.Sno

你这个语句好像没什么用哦,分组的目的一般是用于统计数据,如

select Sno,count(*) from sc where cno<>'1' group by sno