mardi 25 février 2020

Laravel - Calculated query with join inside it

I'm beginning with Laravel ORM Eloquent and i would like to do a query with some calculated fields that depend on 2 tables. So i have to do a subquery inside the calculated query but i don't know how to do that with the Eloquent query builder.

Example of query that i want to do :

select * , 
(select activites.id_activites from activites inner join insc_ses on insc_ses.id_activites=activites.id_activites where id_session=1 
and insc_ses.id_inscription=inscriptions.id_inscription) activite_session1, 
(select activites.id_activites from activites inner join insc_ses on insc_ses.id_activites=activites.id_activites where id_session=2 
and insc_ses.id_inscription=inscriptions.id_inscription) activite_session2, 
(select activites.id_activites from activites inner join insc_ses on insc_ses.id_activites=activites.id_activites where id_session=3 
and insc_ses.id_inscription=inscriptions.id_inscription) activite_session3 
from inscriptions

Is that possible to do ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32nfzHM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire