当前位置:网站首页>“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
2022-04-23 07:22:00 【qq_ fifteen million one hundred and ninety-seven thousand four 】
Problem description
sql:
SELECT ID ,COUNT(ID) as favoriteCount,productID FROM l_favorite GROUP BY productID
Report errors :
MySql.Data.MySqlClient.MySqlException:“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘lec.l_favorite.ID’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by”
Cause analysis :
It felt strange at first , Run in the database management tool without error ,EF You'll report a mistake again . And there are times mistakes , Sometimes they don't report .
First, I directly searched the error content , Then a bunch of articles are written directly , Get rid of mysql In the configuration file sql_mode=ONLY_FULL_GROUP_BY To configure .
It's very speechless , Don't say the reason for the error , It doesn't solve the problem , Directly solve the configuration items that generate errors , Since the default configuration is like this , That must make sense , Don't change the configuration easily , It's not a good habit .
Then translated this paragraph in English , Probably means to say ID This field has no aggregation .
Well, … Looked at the sql, I'm careless , many select There's a ID Field , And the grouping field is productID . Cause the database to think , Put several different ID Aggregate into one ID, It's illegal .
Solution :
hold select There is no aggregation behind ID Just remove the field .
版权声明
本文为[qq_ fifteen million one hundred and ninety-seven thousand four ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230609264857.html
边栏推荐
猜你喜欢
随机推荐
The Cora dataset was trained and tested using the official torch GCN
[2021 book recommendation] red hat rhcsa 8 cert Guide: ex200
torch.mm() torch.sparse.mm() torch.bmm() torch.mul() torch.matmul()的区别
Reading notes - activity
Pytoch model saving and loading (example)
【点云系列】Pointfilter: Point Cloud Filtering via Encoder-Decoder Modeling
winform滚动条美化
【点云系列】 场景识别类导读
常见的正则表达式
【点云系列】Fully-Convolutional geometric features
Record WebView shows another empty pit
【点云系列】点云隐式表达相关论文概要
【点云系列】SO-Net:Self-Organizing Network for Point Cloud Analysis
Minesweeping games
【动态规划】不同的二叉搜索树
Miscellaneous learning
[dynamic programming] longest increasing subsequence
torch_ Geometric learning 1, messagepassing
PyMySQL连接数据库
Machine learning II: logistic regression classification based on Iris data set








