当前位置:网站首页>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
边栏推荐
- Download PDF from HowNet (I don't want to use CAJViewer anymore!!!)
- MySQL uses or to query SQL, and SQL execution is very slow
- MySQL - index
- Introduction to raspberry pie 3B - system installation
- C. Tree Infection(模拟+贪心)
- PHP 统计指定文件夹下文件的数量
- View, modify and delete [database] table
- TypeError: ‘Collection‘ object is not callable. If you meant to call the ......
- 用LCR表完美测试无线充电系统中的线圈
- redis和mysql区别
猜你喜欢

Introduction to raspberry pie 3B - system installation
![[winui3] Écrivez une copie du gestionnaire de fichiers Explorer](/img/3e/62794f1939da7f36f7a4e9dbf0aa7a.png)
[winui3] Écrivez une copie du gestionnaire de fichiers Explorer

拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!

深度学习笔记 —— 语义分割和数据集

Deep learning notes - data expansion

CLion+OpenCV identify ID number - detect ID number

Innovation training (IX) integration
![[winui3] write an imitation Explorer file manager](/img/3e/62794f1939da7f36f7a4e9dbf0aa7a.png)
[winui3] write an imitation Explorer file manager

【数据库】MySQL基本操作(基操~)

Painless upgrade of pixel series
随机推荐
C. Tree infection (simulation + greed)
MySQL uses or to query SQL, and SQL execution is very slow
敏捷实践 | 提高小组可预测性的敏捷指标
负载均衡简介
A trinomial expression that causes a null pointer
Com alibaba. Common methods of fastjson
Special topic of data intensive application system design
[database] MySQL single table query
Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
ApplicationContext injection bean
Progress of innovation training (III)
Innovation training (10)
The 2021 more reading report was released, and the book consumption potential of post-95 and Post-00 rose
MySQL memo (for your own query)
Mac enters MySQL terminal command
解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
退出vim的方法
[2021] Spatio-Temporal Graph Contrastive Learning
[2021] Spatio-Temporal Graph Contrastive Learning
Excel protects worksheets and workbooks from damage