mercredi 19 juin 2019

Laravel Multiple Join result issue

I have following multiple join query in Laravel

$UserRequests = UserRequests::join('destinations', 'destinations.id', '=', 'destination_id')->leftJoin('request_process', function($join){        
        $join->whereRaw('request_id in (SELECT request_id FROM request_process GROUP by request_id having max(ticket_status)!=2)');
    }
)
    ->select('process_id','destination_id', 'user_requests.id','name','location','plan_id', 'visit_date','quantity','ticket_status')
    ->get();

It produces results with ticket_status=null if there is:

ticket_status!=2

What I want:

  1. It give results if no record in subsequet tables except UserRequests
  2. It should not give result if ticket_status!=2


from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2XuF0aE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire