zoukankan      html  css  js  c++  java
  • 小问题

    Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'platform_test.p.positional' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

    解决办法:

    MySQL 5.7.5后only_full_group_by成为sql_mode的默认选项之一,这可能导致一些sql语句失效。

    解决方法
    把group by字段group_id设成primary key 或者 unique NOT NULL。这个方法在实际操作中没什么意义。

    使用函数any_value把报错的字段name包含起来。如,select any_value(name), group_id from game group by group_id。

    在配置文件my.cnf中关闭sql_mode=ONLY_FULL_GROUP_BY.。msqyl的默认配置是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去掉,也可以去掉所有选项设置成sql_mode=,如果你确信其他选项不会造成影响的话。

     eg:

      

    SELECT
        su.user_id,
        su.user_no,
        su.create_user,
        su.create_time,
        su.update_user,
        su.update_time,
        i.NAME,
        i.sex,
        i.contact,
        a.start_time,
        a.education,
        b.positional,
        b.obtain_time,
        i.dept_id
    FROM
        user_info i
        LEFT JOIN sys_user su ON su.user_id = i.user_id
        LEFT JOIN (
    SELECT
        any_value(e.education) education,
        MAX( e.start_time ) start_time,
        any_value(e.id) id,
        e.user_id
    FROM
        user_education e
    GROUP BY
        e.user_id
    ORDER BY
        start_time DESC
        ) a ON a.user_id = i.user_id
        LEFT JOIN (
    SELECT
        any_value(p.positional) positional,
        MAX( p.obtain_time ) obtain_time,
        any_value(p.id) id,
        p.user_id
    FROM
        user_positional p
    GROUP BY
        p.user_id
    ORDER BY
        obtain_time DESC
        ) b ON b.user_id = i.user_id
    WHERE
        i.user_id != '1'
  • 相关阅读:
    「AtCoder AGC023F」01 on Tree
    「Wallace 笔记」平面最近点对 解法汇总
    「Codeforces 1181E」A Story of One Country (Easy & Hard)
    「NOI2018」「LOJ #2720」「Luogu P4770」 你的名字
    IdentityServer4设置RefreshTokenExpiration=Sliding不生效的原因
    【知识点】IQueryable.SumAsync方法的NULL异常
    Beyond Compare 4 密钥被吊销
    【知识点】Uri对象的完整地址
    git文件夹大小写问题
    .Net Core学习资料
  • 原文地址:https://www.cnblogs.com/NCL--/p/11532077.html
Copyright © 2011-2022 走看看