zoukankan      html  css  js  c++  java
  • 最近升级mysql5.7出现下面问题,ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by

    执行sql:

    SELECT * FROM `user_link` WHERE `group_id` IN ('78', '79') GROUP BY `link_id`   

    报错:

    SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'user_link.group_id' which is not functionally dependent on columns in GROUP BY clause; 
    this is incompatible with sql_mode=only_full_group_by The SQL being executed was: SELECT * FROM `user_link` WHERE `group_id` IN ('78', '79') GROUP BY `link_id`

    执行查看:select @@sql_mode;

    里面默认设置了:sql_mode=only_full_group_by

    only_full_group_by :使用这个就是使用和oracle一样的group 规则, select的列都要在group中,或者本身是聚合列(SUM,AVG,MAX,MIN) 才行,其实这个配置目前个人感觉和distinct差不多的,所以去掉就好

    或者修改sql语句

  • 相关阅读:
    HNOI2008玩具装箱
    CEOI2004锯木厂选址
    APIO2010特别行动队
    【HNOI2011】数学作业
    【JLOI2015】城池攻占
    魔法猪学院
    Kruskal重构树(货车运输)
    旋转卡壳求凸包直径
    Graham凸包算法简介
    poj-3169Layout
  • 原文地址:https://www.cnblogs.com/zhja/p/9111059.html
Copyright © 2011-2022 走看看