Laravel:语法错误或访问冲突:1055 错误 [英] Laravel : Syntax error or access violation: 1055 Error
问题描述
我想在同一个查询中使用 WhereIn 和 Groupby 来获取结果.
I want to use WhereIn and Groupby in the same query to fetch Result.
我已经试过了:
$loadids=explode("#@*",$reciptdet->loading_id);
$loadingdatas=DB::table('loading')->groupBy('vehicle_no')->whereIn('id',$loadids)->get();
但我收到此错误消息:
SQLSTATE[42000]: 语法错误或访问冲突: 1055 'sbrtpt.loading.id' is not in GROUP BY (SQL: select * from loading where id in (14, 15, 16) group by vehicle_no)
SQLSTATE[42000]: Syntax error or access violation: 1055 'sbrtpt.loading.id' isn't in GROUP BY (SQL: select * from loading where id in (14, 15, 16) group by vehicle_no)
推荐答案
简短回答
在 configdatabase.php
--> "mysql"
数组
设置 'strict' =>false
禁用所有.
你可以离开 'strict' =>true
并将模式添加到
You can leave 'strict' => true
and add modes to "mysql"
option in
'mysql' => [
...
....
'strict' => true,
'modes' => [
//'ONLY_FULL_GROUP_BY', // Disable this to allow grouping by one column
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_AUTO_CREATE_USER',
'NO_ENGINE_SUBSTITUTION'
],
]
<小时>
详细解答
您可能不需要禁用所有严格选项...请查看有关此问题的答案.
Detailed answer
You may not need to disable all strict options ... Kindly have a look on this answer about this issue.
这篇关于Laravel:语法错误或访问冲突:1055 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!