group by column 报错:this is incompatible with sql_mode=only_full_group_by

MySQL5.7.5后only_full_group_by成为sql_mode的默认选项,导致使用group by进行分组查询报错
this is incompatible with sql_mode=only_full_group_by

默认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
 
执行以下两条SQL命令去除ONLY_FULL_GROUP_BY,解决group by报错:
SET GLOBAL sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

 

posted @ 2020-12-24 18:56  史亚运  阅读(146)  评论(0编辑  收藏  举报