当前位置:网站首页>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
边栏推荐
- 静态流水线和动态流水线的区别认识
- Sword finger offer: the median in the data stream (priority queue large top heap small top heap leetcode 295)
- Pixel mobile phone brick rescue tutorial
- JS détermine si la chaîne de nombres contient des caractères
- Innovation training (XII) reptile
- Learning Android II from scratch - activity
- 独立站运营 | FaceBook营销神器——聊天机器人ManyChat
- [database] MySQL multi table query (I)
- 解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
- Thoughts on a small program
猜你喜欢
Cross border e-commerce | Facebook and instagram: which social media is more suitable for you?
DIY is an excel version of subnet calculator
Perfect test of coil in wireless charging system with LCR meter
深度学习笔记 —— 数据增广
Innovation training (VI) routing
直播带货表格模板-自动显示图片-自动关联系列商品
Basic concepts of multithreading (concurrency and parallelism, threads and processes) and entry cases
Independent station operation | Facebook marketing artifact - chat robot manychat
深度学习笔记 —— 语义分割和数据集
Solve valueerror: argument must be a deny tensor: 0 - got shape [198602], but wanted [198602, 16]
随机推荐
【数据库】MySQL单表查询
leetcode——启发式搜索
CLion+OpenCV identify ID number - detect ID number
C. Tree Infection(模拟+贪心)
Unity C e-learning (IV)
getprop 属性
机器学习---线性回归
[database] MySQL single table query
Mac 进入mysql终端命令
QPushbutton 槽函数被多次触发
What are the redis data types
[WinUI3]编写一个仿Explorer文件管理器
Windows remote connection to redis
负载均衡简介
MySQL - index
C# List字段排序含有数字和字符
COM in wine (2) -- basic code analysis
Innovation training (IX) integration
【数据库】MySQL多表查询(一)
Sword finger offer: symmetric binary tree (recursive iteration leetcode 101)