Why wouldnt all IDs be unique ?
Nov 17, 2022
6
Level 8
take() for each unique id
Hello, If I have the following query:
Table::whereIn('id', $ids_arr)->get();
Is it possible to use something like take(5) but for each unique id?
Thanks
Level 102
@Ligonsker Ah ok. You need to write some sort of windows function for that. Cannot write it off the top of my head, but I can help you google for it.
Edit: something like this: https://ubiq.co/database-blog/mysql-select-top-n-rows-per-group/
1 like
Please or to participate in this conversation.