I Have This SQL Query Working And I Want To Migrate To The Laravel Query Builder Format
Today is working with this SQL Query.
SELECT me.id FROM refrees r LEFT JOIN matches m ON m.refree_id = r.id LEFT JOIN match_events me ON m.id = me.match_id WHERE r.id = 1 AND me.match_event_type_id = 2
I have tried it, but its not working.
$c = DB::table('refrees as r') ->leftJoin('matches as m', 'r.id', '=', 'm.refree_id') ->leftJoin('match_events as me', 'me.id', '=', 'm.id') ->where('r.id', '=', '1') ->where('me.match_event_type_id', '=', '2') ->select('me.id') ->get();
My bad. It was
->leftJoin('match_events as me', 'me.id', '=', 'm.id')
where I would put
->leftJoin('match_events as me', 'me.id_match', '=', 'm.id')
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?