[Err] 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated colum

错误信息:

[Err] 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'scp.m.manufacturer_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

翻译信息:

 [Err] 1055 - ORDER BY子句的表达式#1不在GROUP BY子句中,并且包含非聚合列'information_schema.PROFILING '。SEQ'在功能上不依赖于GROUP BY子句中的列;这与sql_mode=only_full_group_by不兼容

错误场景:

上传云服务器连接云端数据库时查询出错,本地MySQL查询正常,云端报错,例子在下文图1、2述说。

错误原因:

Group By函数需要包含前面查询的列~

由于默认的 MySQL 配置中 sql_mode 配置了 only_full_group,需要 GROUP BY 中包含所有 在 SELECT 中出现的字段。

  • 解决方式:

将前面的列摆在后面,你要我怎样,我就怎样

  • 其他方式:

其他方式详情见:https://blog.csdn.net/loveliness_peri/article/details/88051316

举栗子:

  • 错误栗子:

[Err] 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated colum_第1张图片

图1


  • 正确栗子:

[Err] 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated colum_第2张图片 图2


【原创系列】原文地址:https://blog.csdn.net/qq_43227967/article/details/88921248

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(MySql,小问题)