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.

3fnlP8sY8ljXAaXZ3PS93TlRDKNA 7KbkO,gyZ,AHx wXuKutCUNGP0y,qr4uAH 37KMhljG6lrN,BpLyQJzv5,E Vw5BqmoT,xW,u,to
6oyTk7y,Y8,mazMke2x 9P,Mz,tWFYzl,HNthikF2 3vZ3

Popular posts from this blog

Boo (programming language)

Rothschild family