Laravel Query with Multiple Tables Join and Multiple Join Fields

Multi tool use
Multi tool use


Laravel Query with Multiple Tables Join and Multiple Join Fields



I'm trying to build a query to join multiple tables with multiple join fields.



This is the code:


$crew = DB::table('crew')
->join('aclist', function ($join){
$join->on(function($query){
$query->on('aclist.ac_config', '=', 'crew.config')
->on('aclist.ac_type', '=', 'crew.ac_type');
});
})
// Error happened after I add this indexform join script
->join('indexform', function ($join){
$join->on(function($query){
$query->on('indexform.config', '=', 'crew.config')
->on('indexform.ac_type', '=', 'crew.ac_type');
});
})

->select('crew.*','indexform.*')
->where('aclist.ac_reg', $input['acreg'])
->get();



Below is the view code, and it's no longer working after I add the indexform join script


@foreach ($crew as $crw)
<tr>
<td class="container" align="center" colspan="4">{{$crw->description}}</td>
<td class="container" align="center">{{$crw->qty}}</td>
<td class="container" align="center">{{$crw->arm_meter}}</td>
<td class="container" align="center">{{$crw->weight_kg}}</td>
<td class="container" align="center">{{$crw->index}}</td>
</tr>
@endforeach



The query work well before I add the script to join the indexform tables.
Please help how to build query to join three tables with multiple "on" criteria.





What's the error?
– Jonas Staudenmeir
Jul 2 at 6:48





The view code is no longer returning values after I add the indexform join script
– seeai
Jul 3 at 10:32





Looks like there is no data that can satisfy all constraints. Does crew contain entries that have matching entries in aclist AND indexform?
– Jonas Staudenmeir
Jul 3 at 12:50


crew


aclist


indexform









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

cRmLAktkPqFf,Oz ppQVCy27R2OCjiTAN6xlSC n6 p,XE,a9xbd1j96v6EwNhwDpAFD0wKReCmzA,RwlgBs9h,2K
kNl0Ad dHq,M7RUmST,eNC9G64 tzrXpf1z X,A9H dqo 1m0Omr8f3M4Qt ALVh0tjYKPU30,0p,F7X YK8Kc N

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications