records = Student::with(array('Mark' => function($marks)
{
$marks->select(DB::raw('sum(obtain_marks)'))->with(array('Subject' => function($subject){
$subject->orderby('subject_name')->select(DB::raw('count(subjects.id)','sum(total_marks)','subject_name'));
}));
}))->where('id', $id)->get();
为什么这没有执行?
它在 mysql 中工作 select count(subjects.id),sum(subjects.total_marks),sum(marks.obtain_marks),subjects.subject_name from students 内部连接标记 students.id = 标记.student_id 内部连接subjects.id = mark.subject_id where students.id = 20 group by subject.subject_name; 它在mysql中工作。