R
R
Rodion Yurchenko2015-08-18 08:13:09
Ruby on Rails
Rodion Yurchenko, 2015-08-18 08:13:09

How to pull two or more random records from a database?

Good afternoon !
There is a table where there are n records
How to pull out 2 or more RANDOM records in 1 request
so that each one is random, not the first one is random - and the second one is 1 more, but so that it is completely random

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
VoidVolker, 2019-02-15
@Demigodd

Of course, for example:Model_1__Or__Model_2

S
Sergey, 2015-08-18
@aassdds

SELECT * FROM tbl ORDER BY RAND() LIMIT 2;

V
Vitaly Inchin ☢, 2015-08-18
@In4in

One , Two , Three ... Five hundred ...
Did you go to Google?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question