有人可以帮我将下面的 mysql 转换为 laravel db query builder 或 eloquent 吗?这是我的 mysql
SELECT max(created_at), jobseeker_id,call_reason,type_of_call
FROM calllogs
GROUP BY jobseeker_id
ORDER BY created_at DESC;
这是我的尝试,但还没有成功。
$jobseekers =DB::table('calllogs')
->select(DB::raw("max('created_at'),jobseeker_id"))
->groupBy('jobseeker_id')
->orderBy('created_at','desc')
->get();
dd($jobseekers);
请帮帮我。
最佳答案
$jobseekers =DB::table('calllogs')
->select(DB::raw("max(created_at),jobseeker_id"))
->groupBy('jobseeker_id')
->orderBy('created_at','desc')
->get();
试试这个代码。 最多只删除 ' ' 它会很好用。
关于php - 如何在数据库查询生成器中分组以获得唯一值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47871825/