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

前端 未结 14 1611
太阳男子
太阳男子 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:15

    Note that groupBy as used above won't work for postgres.

    Using distinct is probably a better option - e.g. $users = User::query()->distinct()->get();

    If you use query you can select all the columns as requested.

提交回复
热议问题