I have DB table urls
similar to this
id | user_id | name
----------------------------
1 | 56 | John
2 | 25 | Carry
3 | 56 | Jim
4 | 12 | Jolana
5 | 12 | Ava
What I need to do is to select the rows with the first occurance of user_id
ordered in DESC by id
. In this case it would mean to select rows with IDs 5
, 3
and 2
.
Can this be achieved somehow using Eloquent, or if not, pure SQL? I can imagine writing a script for this but I would like to make it work with one query.