使用Navicat每执行一条查询语句都报错
虽然不影响查询结果
但是看见了总是不爽
[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
于是问度娘
据说
大概意思是。。。是select的都要group by但是你没有。所以报错。。。
解决方案一(1):
SHOW VARIABLES LIKE '%sql_mode%';
查看下SQL的模式
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。
存在 ONLY_FULL_GROUP_BY
修改sql_mode的值
set sql_mode = '';
set sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';
(似乎有点狠,我用下一个方案)
解决方案一(2):
查看sql_model:
select @@global.sql_mode;
查询到的结果:
去掉ONLY_FULL_GROUP_BY
,重新设汁
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';
解决方案二:
找到mysql解压目录,我的是D:\mysql\bin
找到my.ini文件加入这句话
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
把only_full_group_by
这个值去掉了