My records in 'answers table':
**id question_id answer**
20 12 app/Http/routes.ph
21 13 uri
22 13 closure
23 14 controller
24 15 class name
25 15 App\Http\Controllers
26 16 for displayh
My code to retrieve data:
$qas= DB::table('answers')
->groupBy('question_id')
->get();
dump($qas);
}
I get only 5 records instead of 7; where the other 2 records? It works similarly to distinct function which is not my intention.
How to write code to get all 7 record which are grouped by 'question_id'?