从mysql获取随机记录
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从mysql获取随机记录相关的知识,希望对你有一定的参考价值。
get some random record from mysql quickly。
SELECT * FROM `table` AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM `table`)-(SELECT MIN(id) FROM `table`))+(SELECT MIN(id) FROM `table`)) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id LIMIT 1;
以上是关于从mysql获取随机记录的主要内容,如果未能解决你的问题,请参考以下文章