首页  »   MySQL

mysql 出错解决 sql_mode=only_full_group_by

网友分享于:2017-12-17  浏览:0次
mysql 报错解决 sql_mode=only_full_group_by

ql语句报错问题

#1055 - Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘cash.sdb_login_log.id‘ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

###

 

官方文档的解决方法

https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-setting

 

查询mysql服务器版本:
select @@version
显示:
5.7.10
select @@GLOBAL.sql_mode;
显示结果:
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

#查看sql_mode的语法
select @@GLOBAL.sql_mode;
select @@SESSION.sql_mode;

#修改sql_mode的语法 ,去掉ONLY_FULL_GROUP_BY,重新set model

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‘;
SET SESSION sql_mode = ‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘;
或者 

 

非全局模式:set @@sql_model=‘’;

全局模式    :set @@GLOBAL.sql_mode=‘’;

相关解决方案

最新解决方案