使用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就不报错了。

 

相关文章:

  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2021-06-27
  • 2021-12-24
  • 2021-12-30
  • 2022-12-23
  • 2021-10-25
相关资源
相似解决方案