当前位置:网站首页>SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP
2022-06-21 15:39:00 【51CTO】
原因分析
一、原理层面
这个错误发生在mysql 5.7 版本及以上版本会出现的问题:
mysql 5.7版本默认的sql配置是:sql_mode="ONLY_FULL_GROUP_BY",这个配置严格执行了"SQL92标准"。
很多从5.6升级到5.7时,为了语法兼容,大部分都会选择调整sql_mode,使其保持跟5.6一致,为了尽量兼容程序。
二、sql层面
在sql执行时,出现该原因:
简单来说就是:输出的结果是叫target list,就是select后面跟着的字段,还有一个地方group by column,就是
group by后面跟着的字段。由于开启了ONLY_FULL_GROUP_BY的设置,所以如果一个字段没有在target list
和group by字段中同时出现,或者是聚合函数的值的话,那么这条sql查询是被mysql认为非法的,会报错误。
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
解决方案
打开配置文件my.cnf,添加sql_mode="",然后:wq保存,重启mysql服务即可完美解决
如遇到找不到my.cnf文件,例如mysql8.0源码安装后就没有含此文件,自己手动此文件后配置即可。可参考: mac下安装apache+php+mysql
参考地址:
https://www.jianshu.com/p/bb31e34c8ad7
边栏推荐
- Gmail:如何跟踪邮件阅读状态
- Rk3399 platform development series explanation (network debugging) 7.32. What is network routing?
- Representation learning of resting fMRI data based on variational self encoder
- WEB3 安全系列 || 攻击类型和经验教训
- [number theory] leetcode1006 Clumsy Factorial
- Set up your own website (4)
- 2022awe opened in March, and Hisense conference tablet was shortlisted for the review of EPLAN Award
- Web网页自动化实战《3.在艺龙网中,根据城市+日期+关键词精准匹配了酒店》下篇
- Score-Based Generative Modeling through Stochastic Differential Equations
- Write static multi data source code and do scheduled tasks to realize database data synchronization
猜你喜欢

Using apiccloud to realize document download and Preview

Baota, a well-known server operation and maintenance software manufacturer, joined dragon lizard community and completed compatibility and adaptation with Anolis OS

Goose factory, everything about ThreadLocal
![[pytorch basic tutorial 29] DIN model](/img/13/a180134e149c7ec08ff878f3e3514c.png)
[pytorch basic tutorial 29] DIN model

Go language - structure

The third child is here at last! General intelligent planning platform - APS module

Native JS routing, iframe framework

C multithreading

Merge two ordered linked lists

Analysis report on competition trend and development scale of China's heavy packaging industry 2022-2028 Edition
随机推荐
Using apiccloud to realize document download and Preview
Graph calculation on nlive:nepal's graph calculation practice
33岁程序员的年中总结
WSL 2 installation process (and introduction)
RichardSutton:经验是AI的终极数据,四个阶段通向真正AI的发展之路
[cicadaplayer] read and write of HLS stream
Taishan Office Technology Lecture: storage structure of domain in model
Merge two ordered linked lists
Unity grid programming 09
高级性能测试系列《5.服务器的发展、vmware虚拟技术》
Bookstack: an open source wiki platform
Write commodity table with JSP
Go language - Method
Score-Based Generative Modeling through Stochastic Differential Equations
R语言使用fs包的file_access函数、file_exists函数、dir_exists函数、link_exists函数分别查看文件是否可以访问、文件是否存在、目录是否存在、超链接是否存在
Set up your own website (4)
WSL 2 的安装过程(以及介绍)
Dstream and its basic operating principle
Turn off WordPress auto thumbnail
Gmail: how to track message reading status