当前位置:网站首页>In aggregated query without group by, expression 1 of select list contains nonaggregated column
In aggregated query without group by, expression 1 of select list contains nonaggregated column
2022-04-23 05:01:00 【Chen junyang】
sql Statement error content :
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'sw_promanage.a.id'; this is incompatible with sql_mode=only_full_group_by
Error reason :
MySQL Version of the problem , Some versions are enabled by default ONLY_FULL_GROUP_BY, So it led to some SQL Unable to execute normally , Because group by after , Some of the data returned is indeterminate , That's why this error occurs .
resolvent ( Two kinds of ):
- (1) Use ANY_VALUE(column_name).
for example :
Error code :
SELECT
a.id AS "id",
a.project_id AS "projectId",
sum(a.reward_money) AS "rewardMoney",
sum(a.punish_money) AS "punishMoney"
FROM pm_reward_punishment_plan a
where a.project_id = 'xxxxxxxx'
Modified code :
SELECT
ANY_VALUE(a.id) AS "id",
a.project_id AS "projectId",
sum(a.reward_money) AS "rewardMoney",
sum(a.punish_money) AS "punishMoney"
FROM pm_reward_punishment_plan a
where a.project_id = 'xxxxxxxx'
- (2) Set up the database , close ONLY_FULL_GROUP_BY.
edit my.cnf file , find sql-mode The location of , Get rid of ONLY_FULL_GROUP_BY, restart MySQL service ;
Such as my.cnf There is no sql-mode, You need to add the following :
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION, restart MySQL service .
版权声明
本文为[Chen junyang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220552495294.html
边栏推荐
- 机器学习---线性回归
- Learning Android II from scratch - activity
- MySQL time function query
- 多线程基本概念(并发与并行、线程与进程)和入门案例
- Learning Android from scratch -- Introduction
- CLion+OpenCV identify ID number - detect ID number
- 【数据库】MySQL多表查询(一)
- Implementation of switching windows and capturing data in selenium mode
- This call when the transaction does not take effect
- A trinomial expression that causes a null pointer
猜你喜欢
What are the redis data types
使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
深度学习笔记 —— 微调
拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!
Leetcode 1547: minimum cost of cutting sticks
《2021多多阅读报告》发布,95后、00后图书消费潜力攀升
Wechat payment function
Arduino UNO r3+LCD1602+DHT11
MySQL -- execution process and principle of a statement
Download PDF from HowNet (I don't want to use CAJViewer anymore!!!)
随机推荐
【数据库】MySQL单表查询
js 判斷數字字符串中是否含有字符
Innovation training (V) mid term inspection
《2021多多阅读报告》发布,95后、00后图书消费潜力攀升
Knowledge points sorting: ES6
Getprop property
Download PDF from HowNet (I don't want to use CAJViewer anymore!!!)
[WinUI3]编写一个仿Explorer文件管理器
Pixel mobile phone brick rescue tutorial
Introduction to load balancing
Deep learning notes - semantic segmentation and data sets
Custom switch control
[winui3] Écrivez une copie du gestionnaire de fichiers Explorer
View analysis of scenic spots in ArcGIS
QPushButton slot function is triggered multiple times
TypeError: ‘Collection‘ object is not callable. If you meant to call the ......
COM in wine (2) -- basic code analysis
Wine (COM) - basic concept
独立站运营 | FaceBook营销神器——聊天机器人ManyChat
持续集成(CI)/持续交付(CD)如何彻底改变自动化测试