this is incompatible with sql_mode=only_full_group_by
MySQL版本5.7.14;
SQL語句:
mysql> SELECT id,sex,age FROM users_0 GROUP BY age;
ERROR:
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'testdb.users_0.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
似乎在SELECT后的字段必須全部出現在GROUP BY之后,否則都會出現以上錯誤.
請問什么原因,如何解決?
2016-08-24
set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
2016-09-02
可以查看mysql5.1參考手冊 5.3.2 SQL服務器模式 一節