sql模式设置引起的问题解决办法
作者:??Redrose2100???? 发布时间:2024-01-17 03:38:16
1 报错类似如下
数据库错误: Error querying database. Cause: java.sql.SQLSyntaxErrorException: Expression 39 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.ss.student_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
The error may exist in URL [jar:file:/usr/local/xxxxx.jar!/BOOT-INF/lib/summer-system-4.6.0.jar!/mapper/system/SuOrgProgramMapper.xml]
The error may involve com.ruoyi.system.mapper.SuOrgProgramMapper.selectSuOrgProgramList-Inline
The error occurred while setting parameters
SQL: select sop.*,so.org_name as orgName,sa.activity_name as activityName,sa.activity_name_en as activityNameEN, ss.student_id as matchedStudentId,ss.name as matchedStudentName, su.login_name as email, su.real_name AS firstName, su.nickname as nickname from su_org_program sop inner join su_activity sa on sop.activity_id=sa.activity_id inner join su_org so on so.org_id = sop.org_id left JOIN sys_user su ON sop.main_teacher_id = su.sub left join (select * from su_student_program where is_matched=1) ssp on ssp.org_program_id= sop.org_program_id left JOIN su_student ss on ssp.student_id=ss.student_id WHERE sop.org_id = ? GROUP BY sop.org_program_id
Cause: java.sql.SQLSyntaxErrorException: Expression 39 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.ss.student_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by\n; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Expression 39 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.ss.student_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
2 解决办法
2.1 查看全局sql模式
使用如下m命令:
select @@global.sql_mode;
如下:
mysql> select @@global.sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| @@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 |
+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
2.2 设置全局sql模式
使用如下命令:
SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
如下:
ysql> SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
2.3 查看当前sql模式
使用如下命令:
select @@sql_mode;
如下:
mysql> select @@sql_mode;
+------------------------------------------------------------------------------------------------------------------------+
| @@sql_mode |
+------------------------------------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
2.4 设置当前sql模式
使用如下命令:
set @@sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
如下:
mysql> set @@sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
3 永久生效的解决办法
3.1 找到my.cnf文件
可以使用如下命令查找,一般在 /etc/下或者 /etc/mysql/ 目录下
find /etc/ -name my.cnf
3.2 编辑my.cnf文件
vi /etc/mysql/my.cnf
然后增加以下内容:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
3.3 重启数据库服务
systemctl restart mysqld
来源:https://juejin.cn/post/7097126458585251854


猜你喜欢
- 首先数据库里需要有一个自动编号字段(ID)。然后第一次访问的时候,取出所有记录,定制好每页的记录数PageSize,计算出页数,然后根据页数
- 多页应用每一次页面跳转的时候,后台服务器都会给返回一个新的html文档,这种类型的网站也就是多页网站,也叫做多页应用。为什么多页应用的首屏时
- [1]好好规划自己的路,不要跟着感觉走!根据个人的理想决策安排,绝大部分人并不指望成为什么院士或教授,而是希望活得滋
- <script type="text/javascript">/*<![CDAT
- 目录1、功能介绍2、关键代码2.1 主页功能2.2 添加商品信息2.3 数据库设计商品表前言:  
- #{} 和 ${} 的区别#{} 匹配的是一个占位符,相当于 JDBC 中的一个?,会对一些敏感字符进行过滤,编译过后会对传递的值加上双引号
- Django默认支持Session,并且默认是将Session数据存储在数据库中的修改session存取放在数据库中SESSION_ENGI
- 经过摸索和实践,我把自己的解决方法,写在下面: 说明: 我的Oracle客户端的版本是 oracle 9i, 安装client端的时候,不能
- 本文目标:使用selenium3.0+python3操纵浏览器,打开百度网站。(相当于selenium的hello world)环境基础:p
- 可能是IP没设置好问题:MySQL权限设置正确,但仍无法远程访问。通过telnet发现3306端口未打开。分析:MySQL默认只绑定127.
- 一、pyc文件我们开发一个python脚本,文件的后缀为.py。如果运行这个py文件,Python内部会先将源码文件(.py文件)编译成字节
- 回表在研究mysql二级索引的时候,发现Mysql回表这个操作,往下研究了一下字面意思,找到索引,回到表中找数据解释一下就是:先通过索引扫描
- 举例说明: 在Windows环境下:原本在php4.3.0中运行正常的程序,在4.3.1中为何多处报错,大体提示为:Notice:Undef
- 一、简介简单记录一下存储过程的使用。存储过程是预编译SQL语句集合,也可以包含一些逻辑语句,而且当第一次调用存储过程时,被调用的存储过程会放
- 安装 Tesseract OCRTesseract OCR 是一款由 Google 团队开发的开源 OCR(Optical Characte
- 大家好,今天跟大家分享一个用Python实现的学生学籍管理系统:该代码主体由五个函数组成:1.add_stu() 添加2.del_stu()
- 内容摘要:本文介绍了对数据库的基本操作:数据记录筛选(select),更新数据库(update),删除记录(delete),添加数据记录(i
- Oracle的系统要求企业版:CPU最低PENTIUM200M推荐PENTIUMIII1G以上 内存最低128M推荐512M 硬盘空间系统盘
- 目录利用python反转图片/视频安装库反转效果实现代码项目地址利用python反转图片/视频准备:一张图片/一段视频python库:Pil
- 导读你真的知道CHAR和VARCHAR类型在存储和读取时的区别吗?还是先抛几条结论吧:1、存储的时候,CHAR总是会补足空格后再存储,不管用