select * from s_student group by address > 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'java83.s_student.stuno' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by这段查询语句为什么会报错
时间: 2023-10-23 07:08:05 浏览: 103
MySQL异常:[Err] 1055 – Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nona…
5星 · 资源好评率100%
这段查询语句会报错是因为在 SQL 的严格模式下,GROUP BY 语句需要将所有未聚合的列都包含在 GROUP BY 子句中。而这段查询语句中,SELECT 列表中包含了未聚合的列 stuno,但是却没有在 GROUP BY 子句中出现,因此会报错。
你可以将查询语句修改为以下形式来避免报错:
SELECT * FROM s_student GROUP BY address, stuno;
这样就将未聚合的列 stuno 也加入了 GROUP BY 子句中,从而符合 SQL 严格模式的要求。
阅读全文