How to get distinct values for non-key column fields in Laravel?

前端 未结 14 1390
太阳男子
太阳男子 2020-12-01 09:09

This might be quite easy but have no idea how to.

I have a table that can have repeated values for a particular non-key column field. How do I write a SQL query usin

相关标签:
14条回答
  • 2020-12-01 09:32
    // Get unique value for table 'add_new_videos' column name 'project_id'
    $project_id = DB::table('add_new_videos')->distinct()->get(['project_id']);
    
    0 讨论(0)
  • 2020-12-01 09:34
    $users = User::all();
    foreach($users->unique('column_name') as $user){
        code here..
    }
    
    0 讨论(0)
提交回复
热议问题