I am using laravel 4 and have sql query like this
select a.*, v.* from (select * from application order by id desc)a join vacancy v on a.vacancy_id = v.id group by a.email
my problem is how I can write in query builder
You may try something like this. (untested)
$subQuery = DB::table('application')->orderBy('id', 'desc');
$result = DB::table(\DB::raw("({$subQuery->toSql()}) as a"))
->mergeBindings($subQuery)
->selectRaw("a.*, v.*")
->join('vacancy as v', 'a.vancancy_id', 'v.id')
->groupBy('a.email')
->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.