Suppose I have this set of data:
id name amt
1 john 5
1 john 13
1 john 6
2 doe 3
2 doe 4
3 sue 5
3 sue 10
I want to extract a data that would look like this
name amt
john 5
13
6
doe 3
4
sue 5
10
How do i generate this using Laravel Eloquent query?
You can write your custom queries like as
DB::table('table_name')
->select('name',DB::raw('group_concat(amt)'))
->groupBy('name')
->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.