I use laravel framework. I wrote this query but it shows me an error:
Error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'schools.grade' in 'field list' (SQL: select `students`.`name`, `students`.`lastname`, students.id, max(`schools.grade`) as `grade` from `students` inner join `schools` on `schools`.`id` = `students`.`id` group by `schools`.`id` having `grade` = 6)
my code:
$stu = students::join('schools', 'schools.id',"=", 'students.id')
            ->select('students.name','students.lastname',DB::raw('students.id, max(`schools.grade`) as `grade`'))
            ->groupBy('schools.id')
            ->having('grade','=',$grade)
            ->get();
        dd($stu);
what's wrong? thx
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire