我有这个查询
select est.*, bf.followup as bf_follow, bf.unidad as bf_unidad, bu.unidad as bu_unidad, bu.asistencia as bu_asistencia, bu.calificacion as bu_calificacion
from estudiantes as est
inner join bluecard as bc on bc.estudiante = est.usuario_id
inner join beneficiarios as bene on bene.usuario_creado = est.usuario_id
inner join (
select bluecard, followup, unidad
from bluecard_followups
order by bf_id desc
) bf on (bf.bluecard = bc.bc_id)
left join (
select bluecard, unidad, asistencia, calificacion
from bluecard_unidades
order by bu_id desc
) bu on (bu.bluecard = bc.bc_id)
where bc.status = 1
group by est.usuario_id
limit 500
我知道如何使用雄辩的联接但是自定义联接我不知道如何编写它。
有没有类似的事发生过? 有人用laravel需要这样的查询吗?
帮帮我吧! 谢谢
修改
我像这样运行查询:
$estudiantes = Estudiantes::select(
DB::raw("
select est.*, bene.contrato as nro_contrato, bf.followup as bf_follow, bf.unidad as bf_unidad, bu.unidad as bu_unidad, bu.asistencia as bu_asistencia, bu.calificacion as bu_calificacion
from estudiantes as est
inner join bluecard as bc on bc.estudiante = est.usuario_id
inner join beneficiarios as bene on bene.usuario_creado = est.usuario_id
inner join (
select bluecard, followup, unidad
from bluecard_followups
order by bf_id desc
) bf on (bf.bluecard = bc.bc_id)
left join (
select bluecard, unidad, asistencia, calificacion
from bluecard_unidades
order by bu_id desc
) bu on (bu.bluecard = bc.bc_id)
where bc.status = 1
group by est.usuario_id
limit 500"))
->get();
我收到了这个错误: