完整的信息如下:
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'meritsdb.fa_check_result.modid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
這個錯誤發生在mysql 5.7 版本及以上版本會出現的問題:
mysql 5.7版本默認的sql配置是:sql_mode="ONLY_FULL_GROUP_BY",這個配置嚴格執行了"SQL92標准"。
很多從5.6升級到5.7時,為了語法兼容,大部分都會選擇調整sql_mode,使其保持跟5.6一致,為了盡量兼容程序。
解決辦法:在mysql的配置文件my.ini中找到[mysqld],在[mysqld]下增加配置:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION