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

 

转载于:https://www.cnblogs.com/kingsonfu/p/11492269.html

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐