美文网首页
JAVA错误: Expression #3 of SELECT

JAVA错误: Expression #3 of SELECT

作者: 奋斗滴猩猩 | 来源:发表于2018-12-17 16:29 被阅读10次

    详细错误:

    在浏览器请求接口时
    There was an unexpected error (type=Internal Server Error, status=500). could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
    
    查看console中错误:
    clause and contains nonaggregated column ...
    .which is not functionally dependent on columns in GROUP BY clause; 
    this is incompatible with sql_mode=only_full_group_by
    

    错误原因:对于GROUP BY聚合操作,如果在SELECT中的列,没有在GROUP BY中出现,那么这个SQL是不合法的;
    解决办法:1、检测MySQL版本:select @@version;(我的MySQL版本是5.7.24)
    2、SET GLOBAL sql_mode = ''; (关掉ONLY_FULL_GROUP_BY)
    3、重启MySQL(很重要!!!!);
    参考:https://blog.csdn.net/yalishadaa/article/details/72861737

    相关文章

      网友评论

          本文标题:JAVA错误: Expression #3 of SELECT

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