今天由mysql 5.6升级到5.7的时候,遇到一个group by的错误:
Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘trade.create_time’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原来,执行下面语句发现,默认的sql_mode修改了,变成:ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,而5.6版默认是:NO_ENGINE_SUBSTITUTIONmysql
1sql |
|
没办法,须要去掉ONLY_FULL_GROUP_BY,则执行spa
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'
;
code