当前位置:网站首页>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
边栏推荐
- “我这个白痴,招到了一堆只会‘谷歌’的程序员!”
- Distributed monomer brought by microservice architecture
- Comprehensive learning notes for intermediate network engineer in soft test (nearly 40000 words)
- C multithreading
- The application of RPC technology and its framework sekiro in crawler reverse, encrypting data is a shuttle!
- Score-Based Generative Modeling through Stochastic Differential Equations
- 2 万字 + 30 张图 | 细聊 MySQL undo log、redo log、binlog 有什么用?
- Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of floor mounted laboratory centrifuges in the global market in 2022
- GO语言-结构体
- Brain: machine learning reveals two different neuroanatomical subtypes of schizophrenia
猜你喜欢

Go language - pointer

Encryption market "escape": clearing, selling and running
![[North Asia data recovery] SQLSERVER database encrypted data recovery case sharing](/img/6d/7fc3c563fa1c503cbf09f345a4c042.jpg)
[North Asia data recovery] SQLSERVER database encrypted data recovery case sharing

Mid year summary of 33 year old programmer

Soul app focuses on the social needs of generation Z and has won many awards for its outstanding performance in 2021

【PyTorch基础教程29】DIN模型

Distributed monomer brought by microservice architecture

【贪心】leetcode1005K次取反后数组后的最大值

Typescript (6) function

Soft test intermediate network engineering test site
随机推荐
Warning about UUIDs in MySQL master-slave replication
[redis] string type is basically used
2 万字 + 30 张图 | 细聊 MySQL undo log、redo log、binlog 有什么用?
[North Asia data recovery] SQLSERVER database encrypted data recovery case sharing
Web网页自动化实战《2.在艺龙网中,根据城市+日期+关键词精准匹配了酒店》上篇
Goose factory, everything about ThreadLocal
Blazor overview and routing
Gold, silver and four interviews are necessary. The "brand new" assault on the real topic collection has stabilized Alibaba Tencent bytes
『忘了再学』Shell流程控制 — 36、for循环介绍
[redis] basic operation of key
33岁程序员的年中总结
Turn off WordPress auto thumbnail
我不太想在网上开户,网上股票开户安全吗
Gold, silver and four are coming soon. What do you need to prepare for looking for a job?
The third child is here at last! General intelligent planning platform - APS module
Selection (034) - what is the output of the following code?
Rk3399 platform development series explanation (network debugging) 7.33 network performance optimization
Score-Based Generative Modeling through Stochastic Differential Equations
Comprehensive learning notes for intermediate network engineer in soft test (nearly 40000 words)
Review: effects of repetitive transcranial magnetic stimulation rTMS on resting state functional connectivity