Using MySQL RAND() to avoid ORDER BY RAND()

Viewed 429

I am storing RAND() value in a table on each insert and then I run following query to get random rows from the table.

select id from test where random_value >= RAND() LIMIT 5;

There are total 456 rows in a table but the random value is only picking up first 20-25 records. I ran many times above query but never got id > 21.

You can find queries and results here.

2 Answers
Related