SQL---Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column '

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6


数据库中插入数据或执行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
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

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

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

select version(), @@sql_mode;

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

SQL---Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column

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

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

 

 

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

“SQL---Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column '” 的相关文章