mardi 3 novembre 2015

query join 3 tables on laravel

I have been working on this case for 3 days... Someone might give me a solution for the query report that I would like to create below.

I have 3 tables:

applicants
-id
-user_id
-name
-province_id

applications
-id
-user_id
-university_id

provinces
-id
-province_name

The goal of my query is providing total applicants for each province for on universities. Here is the table for this query

list universities table

Here's my query on MySQL:

select provinces.province_name, count(applicants.id) from provinces  left join applicants on provinces.id = applicants.province_id  join applications on applications.user_id = applicants.user_id--  where applications.university_id = 1 group by provinces.id;

Please provides the answer wether in MySQL or eloquent.. Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire