Answer the question
In order to leave comments, you need to log in
How to select multiple records from db in Laravel?
There is a table, in it more than 100 records.
How can I get multiple records in random order?
Out of order. For example: 1st, 6th, 54th, 74th, 85th.
Answer the question
In order to leave comments, you need to log in
$users = DB::table('users')
->whereIn('id', [1, 2, 3])
->get();
There seems to be no native function now, but you can do this for mysql.ModelName::orderBy(DB::raw('RAND()'))->take(10)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question