This is how I'd do it. This way it's cleaner and working for me.
$img = DB::table('table_name')->select('user_id','post_id','name')
->groupBy('post_id')
->get();
$img = DB::table('table_name')
->select('user_id','post_id','name')
->groupBy('post_id')
->get();
If you're running into this SQLSTATE[42000]: Syntax error or access violation: 1055
error be sure to check that the groupBy parameter is a valid column on the table
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.