thinkphp5+mysql5.7.20 group方法异常解决方法
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'movie.tp_video_tags.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
本人开发环境用的是Mysql5.7
出现这个错误的原因是MySQL5.7版本开启了sql_mode中的“only_full_group_by”,而这个在执行以往版本中带有group by的语句时就会报错。
两种解决方法:
1、修改my.cnf(windows下是my.ini)配置文件,删掉only_full_group_by这一项
2、在不修改MySQL配置文件的情况下,需要修改sql语句来执行。
group by后面的列名&