首页 > 技术文章 > Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'infor

wybim 2019-12-17 22:06 原文

今天在Navicat上执行SQL增删改查数据操作的时候出现了下面这个问题

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

在bing.com网上查看了许多人的总结,解决了这个问题

原因:这是数据库的sql_mode设置的有问题。Mysql可以支持不同的SQL模式,不同的SQL模式会有不同的语法,执行不同的数据校验简查。

首先,可以先查看一下数据库现在的sql_mode的值,sql语句为:

select version(), @@sql_mode;

获取结果可能如下,不同的设置查询出来的有区别:

 

然后可以使用如下语句,去设置自己需要的sql_mode.

SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

 

网上还提供了一劳永逸的方法,但是我只使用了第一条,如果问题还没解决的可以参考原文链接

https://blog.csdn.net/u014520745/article/details/76056170

 

推荐阅读