1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tab

1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'table1.sale_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

执行sql语句报错:

SELECT list的表达式#1不在GROUP BY子句中,它包含非聚合列’table1 '。sale_id’在功能上不依赖于GROUP BY子句中的列;这与sql_mode=only_full_group_by不兼容

解决办法:

在mysql中输入

mysql> set sql_mode =‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’;


在mysql的安装目录下找到其配置文件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

保存文件,重启mysql服务

再次从新查询就OK了!

发布了361 篇原创文章 · 获赞 41 · 访问量 16万+

猜你喜欢

转载自blog.csdn.net/guo_qiangqiang/article/details/103855292