Ad

How Create It In Laravel Query Builder

- 1 answer

SELECT e.match_id, e.team_id FROM matches LEFT JOIN match_events e ON e.match_id = matches.id AND e.match_event_type_id = 1

Ad

Answer

Try this,

   $result = DB::table('matches as M')
          ->leftjoin('match_events as E','E.match_id','=','M.id')
          ->where('E.match_event_type_id',1)
          ->select(['E.match_id','E.team_id'])
          ->get();
Ad
source: stackoverflow.com
Ad