laravel group by 42000 错误解决方法

错误代码:

{“msg”:“SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘fanqiepp_api_test.interest_order.truetotal’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: SELECT member.id,member.username,interest_order.truetotal,sum(interest_order.truetotal) as total_count FROM member INNER JOIN interest_member_relation ON member.id = interest_member_relation.thr_member_id INNER JOIN interest_order ON interest_member_relation.member_id = interest_order.member_id WHERE member.remark IS NULL AND member.level = 3 GROUP BY member.id ORDER BY total_count desc)”,“code”:500}

错误叙述:

laravle里面使用group by的时候,报错上面的错误.使用工具在mysql数据库中直接查询,确实正确的.

解决方法:

在自己的项目中,config/database.php里面 53行,有个数组字段 ‘strict’ => true,是严格模式,更改为它的值由true改为false.

你可能感兴趣的:(MySql)