search

Home  >  Q&A  >  body text

mysql 报错,不太懂

迷茫迷茫2873 days ago719

reply all(5)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 16:19:16

    The fields after normal select can only be fields in group by or aggregate functions, for example:

    select a,max(b) from t group by a;

    But you will find that sometimes other people’s mysql is written like this,

    select a,b,max(c) from t group by a;

    Why don’t others report errors?
    Pay attention to the last sentence of the error messagesql_mode=only_full_group_by
    sql_mode is used to check the legality of the SQL statement. When configured as only_full_group_by, the select field is either the result of the aggregate function or the result of group by field value in .
    Therefore, if you want to ensure that the original sql is executed normally, you can modify the configuration of my.cnf. Comment out sql_mode=only_full_group_by and add a # sign in front

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 16:19:16

    You groupby ymf.u.uid but you didn’t put it in the select field?

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 16:19:16

    Post the sql together

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 16:19:16

    When you use group by, the field you want to select must be in group by, except for aggregate queries.

    reply
    0
  • 迷茫

    迷茫2017-04-17 16:19:16

    Thanks for the invitation. If possible, please post your code. If there is an error, it should be that the field you are querying is not in GROUP BY. For details, it still depends on your sql statement.

    reply
    0
  • Cancelreply