[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
时间: 2023-07-18 10:12:55 浏览: 121
MySQL异常:[Err] 1055 – Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nona…
5星 · 资源好评率100%
这是一个 SQL 语句错误,通常是由于 MySQL 的严格模式(`sql_mode=only_full_group_by`)引起的。在这个模式下,`GROUP BY` 语句必须包含所有的非聚合列,否则将会出现错误。解决这个问题的方法有两种:
1. 修改 `sql_mode` 的值,去掉 `only_full_group_by`。可以在 MySQL 的配置文件中修改,或者在连接 MySQL 时设置 `sql_mode` 的值。
2. 将查询语句中的 `ORDER BY` 子句去掉或者包含在 `GROUP BY` 中,确保所有的非聚合列都被包含在 `GROUP BY` 中。
举个例子,如果你的查询语句是这样的:
```
SELECT column1, column2, SUM(column3)
FROM table
GROUP BY column1
ORDER BY column2;
```
你可以将它修改为:
```
SELECT column1, SUM(column3)
FROM table
GROUP BY column1, column2
ORDER BY column1, column2;
```
或者将 `ORDER BY` 子句去掉:
```
SELECT column1, SUM(column3)
FROM table
GROUP BY column1;
```
阅读全文