I was trying to run this query in laravel:
$siswa = DB::table('siswa')
->join('pengambilankelas', 'siswa.id_siswa', '=', 'pengambilankelas.id_siswa')
->join('subcpmkpengambilan', 'pengambilankelas.id_pengambilanKelas', '=', 'subcpmkpengambilan.id_pengambilanKelas')
->join('tesformatif', 'subcpmkpengambilan.id_subcpmkpengambilan', '=', 'tesformatif.id_subcpmkpengambilan')
->select('siswa.*', 'tesformatif.*', DB::raw('max(tesformatif.nilai_tesFormatif) as max_nilai'))
->groupBy('siswa.id_siswa')
->where('pengambilankelas.id_kelas','=', $id_kelas)
->where('subcpmkpengambilan.id_subCPMK', '=', $currentSubcpmk->id_subCpmk)
->where('subcpmkpengambilan.status_subcpmkpengambilan', '=', 3)
->get();
then i got this error:
SQLSTATE[42000]: Syntax error or access violation: 1055 'dil.siswa.identitas_siswa' isn't in GROUP BY (SQL: select `siswa`.*, `tesformatif`.*, max(tesformatif.nilai_tesFormatif) as max_nilai from `siswa` inner join `pengambilankelas` on `siswa`.`id_siswa` = `pengambilankelas`.`id_siswa` inner join `subcpmkpengambilan` on `pengambilankelas`.`id_pengambilanKelas` = `subcpmkpengambilan`.`id_pengambilanKelas` inner join `tesformatif` on `subcpmkpengambilan`.`id_subcpmkpengambilan` = `tesformatif`.`id_subcpmkpengambilan` where `pengambilankelas`.`id_kelas` = 5 and `subcpmkpengambilan`.`id_subCPMK` = 6 and `subcpmkpengambilan`.`status_subcpmkpengambilan` = 3 group by `siswa`.`id_siswa`)
Query run fine outside laravel. this post tell me to disable strict mode
and it works.
is there a better way without disabling strict mode? is it even save to do so?
ps. I'm sorry the database is in indonesian.