Laravel中使用GroupBy时产生的错误MySQL : isn't in GROUP BY

SQLSTATE[42000]: Syntax error or access violation: 1055 'meal_statistics.food.id' isn't in GROUP BY (SQL: select * from `food` group by `category` limit 20 offset 0)


SQLSTATE[42000]: Syntax error or access violation: 1055 'meal_statistics.food.id' isn't in GROUP BY


今天在使用laravel框架时通过groupBy查询出现了两个错误,然后将查询语句直接放到数据库中执行可以获得正确的结果,在网上查找了一番发现是因为database.php文件中对数据库的配置有一个strict  严格模式  它的值由true改为false就解决了问题




你可能感兴趣的:(Laravel)