【MySQL】sql_mode=only_full_group_by
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘day27db.student.sname’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
这个错误是因为 MySQL 的 sql_mode 配置中启用了 ONLY_FULL_GROUP_BY 模式。这个模式要求:
- SELECT 中的所有非聚合列必须出现在
GROUP BY子句中,或者是聚合函数的结果。 - 如果一列不在
GROUP BY子句中,而又不是通过聚合函数计算得出的,MySQL 无法确定应该返回哪一行的值,因此会报错