mysql--navicat--运行SQL时提示出错信息-1055 - Expression #1 of ORDER BY clause is not in GROUP BYt

出错提示

[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

应对方式

win+r
cmd
mysql -u root -p
mysql> set @@global.sql_mode='NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected, 1 warning (0.02 sec)

设置完成之后,建议重启数据库服务器和从新链接数据库,再作数据库操做mysql

具体参考

具体还能够参考这份更详细的描述web

缘由分析参考:

SQL的grop by 语法为,
select 选取分组中的列+聚合函数 from 表名称 group by 分组的列
从语法格式来看,是先有分组,再肯定检索的列,检索的列只能在参加分组的列中选。sql

因此问题中的,group by 后的 a,b,c是先肯定的。select后的a,b,c才是能够变的。即数据库

如下语句都是正确的:服务器

select a,b,c from table_name group by a,b,c,d;
select a,b from table_name group by a,b,c;
select a,max(a) from table_name group by a,b,c;
1
2
3
如下语句则是错误的:svg

select a,b,c from table_name group by a,b;
select a,b,c from table_name group by a;
1
2
而由于MySQL的强大,它兼容了这个错误!!!
可是在DOS是不能的。因此出现了DOS下报错,而在MySQL中可以查找的状况(其实这个查找的结果是不对的)。

原文:https://blog.csdn.net/qq_26525215/article/details/52139296函数