我正在嘗試獲取一些仍然活躍的學(xué)生的數(shù)據(jù)。即使我在同一張表格中也有來(lái)自不活躍學(xué)生的數(shù)據(jù)。這是學(xué)生關(guān)懷這是學(xué)生班這是我提出的雄辯查詢: StudentAttendance:: select('student_classes.active', 'student_attendances.student_id', 'student_attendances.classroom_id', 'classrooms.classroom', 'attendance_rules.option') ->join('classrooms', 'classrooms.id', '=', 'student_attendances.classroom_id') ->join('attendance_rules','attendance_rules.id', '=', 'student_attendances.attendance_id') ->join('student_classes', 'student_attendances.student_id', '=', 'student_classes.student_id') ->where('attendance_date', date("Y-m-d")) ->orderBy('classrooms.classroom', 'ASC') ->get();SQL:select `student_classes`.`active`, `student_attendances`.`student_id`, `student_attendances`.`classroom_id`, `classrooms`.`classroom`, `attendance_rules`.`option` from `student_attendances` inner join `classrooms` on `classrooms`.`id` = `student_attendances`.`classroom_id` inner join `attendance_rules` on `attendance_rules`.`id` = `student_attendances`.`attendance_id` inner join `student_classes` on `student_attendances`.`student_id` = `student_classes`.`student_id` where `attendance_date` = '2020-02-11' order by `classrooms`.`classroom` asc現(xiàn)在我的雄辯查詢結(jié)果如下:如您所見(jiàn),student_id 22 的classroom_id處于非活動(dòng)狀態(tài),但它似乎處于非活動(dòng)狀態(tài)一次,其余部分處于活動(dòng)狀態(tài)。如果刪除student_classes加入,我不會(huì)得到所有重復(fù)的結(jié)果。目標(biāo)是在 Student 類(lèi)中顯示學(xué)生處于活動(dòng)狀態(tài)(active=1)的今天的所有出勤情況,即使我在“學(xué)生關(guān)注”中進(jìn)行查詢也是如此。
如何根據(jù)另一個(gè)表的值從另一個(gè)表中進(jìn)行選擇 雄辯?
HUH函數(shù)
2022-09-17 17:23:13