站内信部分,使用group分组的时候无法读取数据库

14:21:35    SELECT *, count(id) as cnt from (select * from message order by created_date desc) tt group by conversation_id order by created_date desc limit 0, 2    Error Code: 1055. Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tt.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 0.00022 sec

是因为数据库默认的only_full_group_by SQL模式,先用语句select @@global.sql_mode;查看,结果如下:

站内信部分,使用group分组的时候无法读取数据库这时,只需要修改数据库配置,使用下面语句即可:

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';

设置之后再查看数据库配置:

站内信部分,使用group分组的时候无法读取数据库成功解决问题。