本文介绍了具有两个whereIn的查询子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试运行此查询,直到:
I try to run this query , all is good till :
-> whereIn('statut_licence_id',['1','4'])
->whereIn('statut_licence_id', ['1' , '4'])
这第二个whereIn似乎不起作用,它仅向我显示statut_licence_id = 1而不是4,现在有人如何解决该问题?
this second whereIn seems to not work , it's display me only statut_licence_id = 1 and not also 4 , someone now how to resolve the problem ?
$licencies = Licencies::whereIn('structure_id', $structures->pluck('id'))->whereIn('type_licence_id', ['1', '2', '3', '4', '5']) ->whereIn('statut_licence_id', ['1' , '4']) ->where('valid_licence_id', '1') ->where('lb_assurance_etat' ,'=' , 'Assurée') ->orderBy('created_at', 'DESC') ->paginate(10);问题通过解决:
$licencies = Licencies::whereIn('structure_id', $structures->pluck('id'))->whereIn('type_licence_id', ['1', '2', '3', '4', '5']) ->where(function ($query) { $query->whereIn('statut_licence_id', ['1' , '4']) ->where('valid_licence_id', '1'); }) ->orderBy('created_at', 'DESC') ->paginate(10);推荐答案
尝试使用闭包.
$licencies = Licencies::whereIn('structure_id', $structures->pluck('id'))->whereIn(function ($query){ $query->whereIn('type_licence_id', ['1', '2', '3', '4', '5']) ->whereIn('statut_licence_id', ['1' , '4']); }) ->where('valid_licence_id', '1') ->where('lb_assurance_etat' ,'=' , 'Assurée') ->orderBy('created_at', 'DESC') ->paginate(10);更多推荐
具有两个whereIn的查询子句
发布评论