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 in Mysql?
Have you tried something like this
SELECT *
FROM (
SELECT *
FROM table
LIMIT 50
) sub
ORDER BY RAND()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.