在用Navicat写MySQL命令时,出现以下错误:

[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

首先来看错误提及的sql_mode=only_full_group_by的值的含义:
ONLY_FULL_GROUP_BY:
对于GROUP BY聚合操作,如果在SELECT中的列,没有在GROUP BY中出现,那么将认为这个SQL是不合法的,因为列不在GROUP BY从句中
因为有only_full_group_by,所以我们要在MySQL中正确的使用group by语句的话,只能是select column1 from tb1 group by column1(即只能展示group by的字段,其他均都要报1055的错)
所以我们要使用能正确的使用group by 的话就必须删除掉only_full_group_by

my.ini 找到,设置如下

sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"

标签: none

添加新评论