按不工作分组 - Laravel [英] Group by not working - Laravel
本文介绍了按不工作分组 - Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在 Laravel 5.3 中运行这个简单的查询
I'm not able to run this simple query in Laravel 5.3
$top_performers = DB::table('pom_votes')
->groupBy('performer_id')
->get();
它给了我:
SQLSTATE[42000]: Syntax error or access violation: 1055 'assessment_system.pom_votes.id' isn't in GROUP BY (SQL: select * from `pom_votes` group by `performer_id`)
但是,如果我从错误中复制原始查询并直接在 PhpMyAdmin 中触发,它就可以正常工作.
However if I copy raw query from the error and fire directly in PhpMyAdmin, it works fine.
我已经检查过了:
https://laravel.com/docs/5.3/查询#ordering-grouping-limit-and-offset
如有任何帮助,我们将不胜感激.
Any help would be appricaited.
谢谢,
帕斯沃拉
推荐答案
编辑应用程序的数据库配置文件 config/database.php
Edit your applications's database config file config/database.php
在mysql
数组中,设置strict =>;false
禁用 MySQL 的严格模式
In mysql
array, set strict => false
to disable MySQL's strict mode
这篇关于按不工作分组 - Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文