Ad
How To Write Query Sql On Laravel
I'm new to Laravel 4. I have Query Sql Like this
SELECT at.test_id, MAX(at.result), COUNT(status_assessment_id='2') FROM recruitment_process a LEFT JOIN recruitment_result at ON a.id = at.recruitment_id GROUP BY test_id
I do not know how can I write this on Laravel 4?
Ad
Answer
I haven't checked but you can try this
DB::table('recruitment_process a')
->select('at.test_id', DB::raw('MAX(at.result)'), DB::raw('COUNT(status_assessment_id="2")'))
->leftJoin('recruitment_result at', 'a.id', '=', 'at.recruitment_id')
->groupBy('at.test_id')
->get();
More details here https://laravel.com/docs/4.2/queries
Ad
source: stackoverflow.com
Related Questions
- → "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?
Ad