zoukankan      html  css  js  c++  java
  • Expression #1 of SELECT list is not in GROUP BY clause and contains nonag

    报错信息:

    Expression #1 of SELECT list is not in GROUP BY clause and contains 
    nonaggregated column ‘a.rsc_adj_no’ which is not functionally 
    dependent on columns in GROUP BY clause; this is incompatible with 
    sql_mode=only_full_group_by

    选择列表中的一个不在GROUP BY子句中,它包含非聚合列“ rsc_adj_no ”,在功能上不存在依赖于GROUP BY子句中的列。这与sql_mode = only_full_group_by相悖

    解决方法:

    1. select @@global.sql_mode; 查询结果若包括ONLY_FULL_GROUP_BY,使用 set @@global.sql_mode="xxxx";  (去掉ONLY_FULL_GROUP_BY的其他字符串)重新设置即可

    2. 修改my.cnf 文件后,重启mysql

    [mysqld] 
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

    3. 使用函数any_value把报错的字段name包含起来。如,

      select any_value(rsc_adj_no) rsc_adj_no,any_value(bill_no) bill_no from table group by bill_no;

  • 相关阅读:
    代码编辑
    作业7
    实验 13 综合练习三
    模版 实验二 概要设计
    在线评测系统(OJ)使用方法
    作业 6 结构体
    结构体简介
    实验 10 指针2
    (第一周)软件工程四人组
    (第一周)读《构建之法》
  • 原文地址:https://www.cnblogs.com/chaiquan/p/12052639.html
Copyright © 2011-2022 走看看