Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'homestay.h.livable_number' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
时间: 2023-10-13 09:04:58 浏览: 184
这个错误是由于 SQL 模式设置了 `only_full_group_by`,导致查询中的 `GROUP BY` 子句不完整。
在这种情况下,只能将聚合函数作为 `SELECT` 列的一部分,并且所有未聚合的列都必须出现在 `GROUP BY` 子句中。
如果你确定这个查询中的未聚合列与分组的列相关,可以将 SQL 模式更改为 `traditional` 或者使用聚合函数来解决问题。
相关问题
Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'houmi.driver_assess_info. 日期' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
这个错误是由于你的 SQL 查询中使用了 GROUP BY 子句,而 SELECT 列表中的表达式不在 GROUP BY 子句中,并且包含了非聚合列。根据 SQL 模式设置为 only_full_group_by,MySQL 要求 SELECT 列表中的每个非聚合列都必须在 GROUP BY 子句中出现,并且必须是 GROUP BY 列的函数依赖项。
要解决这个问题,你可以按照以下方法之一进行操作:
1. 将 SELECT 列表中的每个非聚合列都添加到 GROUP BY 子句中。
2. 如果你确实需要使用非聚合列,可以考虑使用聚合函数(如 MAX、MIN、SUM 等)对这些列进行聚合。
3. 如果你确定这些非聚合列的值是相同的(例如,它们来自同一个表),你可以使用任意一个聚合函数(例如 MAX 或 MIN)对它们进行聚合。
请根据你的实际需求选择适合的解决方法。
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'employee.employee.e_no' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
这是一个 SQL 查询错误,意思是您的查询中包含了一个非聚合列,但是在 GROUP BY 子句中没有出现。在严格模式下,MySQL 要求 GROUP BY 中的列必须涵盖所有 SELECT 中的非聚合列。
解决该问题的方法有两种:
1. 在 SELECT 子句中包含所有在 GROUP BY 子句中的列。
2. 禁用 MySQL 的严格模式,可以通过修改 MySQL 的配置文件或者在查询中设置 sql_mode 来实现。例如,可以使用以下语句来禁用严格模式:
```
SET sql_mode = '';
```
请注意,禁用严格模式可能会导致一些潜在的问题,因此应该谨慎使用。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)