美文网首页
only_full_group_by报错

only_full_group_by报错

作者: 眼泪相信快乐 | 来源:发表于2021-11-27 14:45 被阅读0次

报错了:

### Cause: java.sql.SQLSyntaxErrorException: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'xxxxxxx'; this is incompatible with sql_mode=only_full_group_by

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'xxxxxx'; this is incompatible with sql_mode=only_full_group_by


原因是:在调用count(*)聚合方法时, 增加了排序字段,而shardingsphere默认会分表查询前,将聚合排序字段,拼接到count后:

SELECT COUNT( 1 ) , create_time AS ORDER_BY_DERIVED_0 FROM xxxxxx_2022

  ORDER BY create_time DESC

所以去掉排序就好了。

相关文章

网友评论

      本文标题:only_full_group_by报错

      本文链接:https://www.haomeiwen.com/subject/nuiwtrtx.html