报错:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregat

在Navicat中执行SQL语句时,报以下错:

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

解决方法一:
在MySQL中执行:

select version(),
@@sql_mode;SET sql_mode=(SELECT REPLACE(@@sql_mode,‘ONLY_FULL_GROUP_BY’,’’));

这个方法只能解决当前的,最佳答案还是用解决方法二。

解决方法二:
修改MySQL的配置文件 my.ini,在[mysqld] 下面增加代码:

sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’

如图:
报错:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregat
修改完my.ini文件后需要重启一下MySQL服务,如果是windows系统,则执行:
net stop mysql
net start mysql
报错:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregat

上一篇:MySQL : You can't specify target table 'Person' for update in FROM clause


下一篇:Mysql中You can’t specify target table for update in FROM clause错误解决方法