zoukankan      html  css  js  c++  java
  • mysql 5.7 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ...报错

    使用mysql在执行一条插入语句时

    insert into channel(channel_id, channel_no,channel_name) values(1, '1000', "hhh");

    报错:Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' 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不兼容的问题

    解决:去掉sql_mode中的only_full_group_by

    先查看sql_mode:

    show variables like "sql_mode";

    ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION可以看到有ONLY_FULL_GROUP_BY,

    设置去除ONLY_FULL_GROUP_BY:

    set sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

    再次执行插入sql就不报错了。

  • 相关阅读:
    coredump分析
    Sword LRU算法
    C++ STL迭代器失效问题
    Sword DB主从一致性的解决方法
    Sword CRC算法原理
    C语言 按位异或实现加法
    Linux 等待信号(sigsuspend)
    C语言 宏定义之可变参数
    Linux shell字符串操作
    C++ *和&
  • 原文地址:https://www.cnblogs.com/kingsonfu/p/11492269.html
Copyright © 2011-2022 走看看