MySQL - Select specific rows and only then randomize them
When I write 'SELECT * FROM table ORDER BY RAND() LIMIT 50'
mysql has to randomize the entire table then only fetch 50.
What I want to do (in mysql, preferably not in php) is to fetch 50 rows THEN randomize them.
Is there a way to do this 开发者_如何学Cin Mysql?
Have you tried something like this
SELECT *
FROM (
SELECT *
FROM table
LIMIT 50
) sub
ORDER BY RAND()
精彩评论