请将查询翻译成eloquent 我试了2天:
SELECT absens.kelas_id AS kelas_id
, absens.nisn AS nisn
, (SELECT t2.kondisi
FROM absens t2
WHERE ((t2.date = '20170811')
AND (t2.kelas_id = 2)
AND (t2.nisn = absens.nisn)
AND (t2.jam_ke = 0))
) AS Jam 0
FROM absens
WHERE ((absens.date = '20170811')
AND (absens.kelas_id = 2))
GROUP
BY absens.nisn;
答案 0 :(得分:-2)
DB::select(DB::raw("SELECT absens.kelas_id AS kelas_id
, absens.nisn AS nisn
, (SELECT t2.kondisi
FROM absens t2
WHERE ((t2.date = '20170811')
AND (t2.kelas_id = 2)
AND (t2.nisn = absens.nisn)
AND (t2.jam_ke = 0))
) AS Jam 0
FROM absens
WHERE ((absens.date = '20170811')
AND (absens.kelas_id = 2))
GROUP
BY absens.nisn;
")
);
希望我帮助XD