mysql5.7.x:this is incompatible with DISTINCT

DISTINCT关键字经常在MySQL中使用,在mysql5.7以前的版本中一般没有什么问题,但是在5.7以后的版本中会遇到这样的错误

Caused by: java.sql.SQLException: Expression #1 of ORDER BY clause is not in SELECT list, references column ‘game.giftbag0_.create_date’ which is not in SELECT list; this is incompatible with DISTINCT

错误提示DISTINCT不兼容,要么更改SQL,但是对于开发者来讲,sql运行一直都是正常的,可能是mysql 版本升级导致的安全问题,5.7.x安全性提升了很多,解决办法可以考虑修改MySQL配置文件,找到对应的my.cnf或者my.ini

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  • 1

添加该行就ok!

还有一种错也是不兼容的问题导致的

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘nctest.pivot.id’ 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就解决了

from https://blog.csdn.net/feinifi/article/details/54135310

posted @   oceanyang  阅读(371)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示