任何人都可以帮我将此查询转换为laravel 5:
SELECT `id`,`mobile_number`,`shortcode`,`chapter_id`,`message`
FROM tbl_votes
WHERE id in (SELECT MAX(id) from tbl_votes GROUP BY `mobile_number`, position_id)
由于
答案 0 :(得分:0)
搞清楚。感谢
DB::table('votes')->whereIn('id', function($query){
$query->select(DB::raw('MAX(id) as id'))
->from('votes')
->groupBy('mobile_number', 'position_id');
})->where(array('shortcode'=>$shortcode,'position_id'=>$positionId))->get();