mysql5.7.xthis 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就解决了 查看方法 SELECT @@GLOBAL.sql_mode 解决办法,在navicat里所操作的库里执行 SET GLOBAL sql_mode = ‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO _CREATE_USER,NO_ENGINE_SUBSTITUTION '