In my "odds" table I have multiple rows with the same "match_id" I would like to choose only 3 rows per match and then move for another match and again choose 3 rows for that and so on.
Imagine it like distinct but with 3 rows, not only 1.
Is there any way to do it without a loop in laravel 5?
Here is my query which takes multiple (more than 3) rows with the same match_id.
\DB::table('matches as m')
->select([ 'o.id as odd_id',
'o.match_id as match_id',
'o.type_id as type_id',
'o.outcome as outcome',
'o.odd as odd',
'm.date_hour as match_date'
])
->where('m.created_at','>=',\DB::raw('DATE_SUB(NOW(), INTERVAL 24 HOUR)'))
->where('m.status_desc_id','=','1')
->join('odds as o', function ($join) {
$join->on('m.id', '=', 'o.match_id')
->where('o.type_id', '=', 43);
})
->groupBy('o.id')
->get();
Thanks.