Linked Questions

Popular Questions

How to use select in laravel on left outer join as second criteria

Asked by At

I am trying to convert this mysql block to laravel sql but could not succeded in anyway

     , m1.userid
     , m2.userid 
  from tbltickets tt 
  join tblticketreplies m1 
    on = m1.tid 
  join tblticketreplies m2 
    on m1.tid = m2.tid 
   and =
     (SELECT min( 
       FROM tblticketreplies m3 
      WHERE > 
        and m3.tid=m1.tid) 
 where > NOW() - INTERVAL 1 MONTH;

Laravel Block :

        $rows = DB::table('tbltickets')
        ->join('tblticketreplies as m1', '', '=', 'm1.tid')
        ->leftJoin("tblticketreplies as m2", function($join) {
            $join->on('m2.tid', '=', 'm1.tid');
            $join->on('',"=",DB::raw("SELECT min( FROM tblticketreplies m3 WHERE > and m3.tid=m1.tid"));
        ->select(' as id, as first, as second, as third ,m1.userid as fid,m2.userid as sid')

does any body know how to use select in outer join or does it possible to do it ?

Related Questions