解决MySQL 5.7.9版本sql_mode=only_full_group_by问题,this is incompatible with sql_mode=only_full_group_by错误
2017-08-07 16:22
861 查看
==============================记录Start=======================
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'database_tl.emp.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原因:
看一下group by的语法:
select 选取分组中的列+聚合函数 from 表名称 group by 分组的列
从语法格式来看,是先有分组,再确定检索的列,检索的列只能在参加分组的列中选。
查找原因:
查看mysql版本命令:select version();
查看sql_model参数命令:
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.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
第一项默认开启ONLY_FULL_GROUP_BY,
解决方法:
1.只选择出现在group by后面的列,或者给列增加聚合函数;
2.命令行输入:
set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
如果上面设置完成后依然报错,这里执行下面的SQL,将全局设置更改,然后必须关闭现有的连接,重新打开连接后查询即可
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';
默认关掉ONLY_FULL_GROUP_BY!
更改完之后可以查看sql_mode:
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
相关参考网址:
https://segmentfault.com/a/1190000005936172 http://blog.csdn.net/u014520745/article/details/76056170
==============================记录End=======================
这篇文章主要介绍了解决MySQL 5.7.9版本sql_mode=only_full_group_by问题,需要的朋友可以参考下
今天在使用MySQL命令行进行分组时报错:ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'database_tl.emp.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原因:
看一下group by的语法:
select 选取分组中的列+聚合函数 from 表名称 group by 分组的列
从语法格式来看,是先有分组,再确定检索的列,检索的列只能在参加分组的列中选。
查找原因:
查看mysql版本命令:select version();
查看sql_model参数命令:
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.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
第一项默认开启ONLY_FULL_GROUP_BY,
解决方法:
1.只选择出现在group by后面的列,或者给列增加聚合函数;
2.命令行输入:
set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
如果上面设置完成后依然报错,这里执行下面的SQL,将全局设置更改,然后必须关闭现有的连接,重新打开连接后查询即可
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';
默认关掉ONLY_FULL_GROUP_BY!
更改完之后可以查看sql_mode:
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
相关参考网址:
https://segmentfault.com/a/1190000005936172 http://blog.csdn.net/u014520745/article/details/76056170
==============================记录End=======================
相关文章推荐
- 解决:mysql 5.7.9 [Err] 1055 ...this is incompatible with sql_mode=only_full_group_by
- [置顶] 【mysql 使用错误解决】this is incompatible with sql_mode=only_full_group_by
- mysql5.7.9新特性this is incompatible with sql_mode=only_full_group_by
- mysql 5.7 this is incompatible with sql_mode=only_full_group_by 问题
- 解决 this is incompatible with sql_mode=only_full_group_by Details 问题 3ff0
- MySQL Error this is incompatible with sql_mode=only_full_group_by
- MySQL分组查询时出现错误SELECT list is not in GROUP BY ;this is incompatible with sql_mode=only_full_group_by
- mysql查询报错: ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by
- mysql5.7 命令gruop by报错 this is incompatible with sql_mode=only_full_group_by
- mysql语法错误:this is incompatible with sql_mode=only_full_group_by
- 解决MySQL 5.7.9版本sql_mode=only_full_group_by问题
- MySQL 5.7.9版本sql_mode=only_full_group_by问题
- this is incompatible with sql_mode=only_full_group_by
- MySQL 5.7.9版本sql_mode=only_full_group_by问题
- SELECT list is not in GROUP BY clause and contains nonaggregated column this is incompatible with sql_mode=only_full_group_by
- MySQL 5.7.9版本sql_mode=only_full_group_by问题
- mysql 1055错误的解决办法 【MYSQL5.7版本sql_mode=only_full_group_by问题】
- this is incompatible with sql_mode=only_full_group_by
- MySQL 5.7.9版本sql_mode=only_full_group_by问题 用到GROUP BY 语句查询时com.mysql.jdbc.exceptions.jdbc4.MySQLSyn
- mysql5.7建表时报错clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by