如何使用laravel查询构建器来获取计数,不同和总国家/地区

时间:2018-05-24 02:46:58

标签: php laravel laravel-5 laravel-query-builder

我想使用laravel查询构建器根据参加比赛的国家进行计算。

Table country:
------------------
country_id
country_name

Table company:
-----------------
company_id
company_name
country_id(fk)

Table_participate_company:
-------------------------
company_id
competition_id

Table competition:
--------------------
competition_id
competition_name

示例输出:

Sample output

我当前的查询:

$total = DB::table('company')
                    ->join('participate_company', 'company.company_id', '=','participate_company.company_id')
                    ->join('country', 'company.country_id', '=','country.country_id')  
                    ->get();

0 个答案:

没有答案