开发者

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() 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜