mysql报错: group by --SELECT list is not in GROUP BY clause and contains nonaggregated column

用group by 查询时抛出如下异常:

Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.t_long.user_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

解决:
修改MySQL 配置文件 sql_mode,去掉only_full_group_by
参考博客:
https://www.cnblogs.com/jpfss/p/10401753.html

法二:
将select中的所有字段放到 group by 后面
参考博客:
https://blog.csdn.net/qq_41737716/article/details/80566407

你可能感兴趣的:(数据库,mysql)