MYSQL 中随机读取一条数据
SELECT * FROM res AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM res) - (SELECT MIN(id) FROM res)) + (SELECT MIN(id) FROM res)) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id LIMIT 1;
select * FROM `res` AS t1 JOIN(SELECT ROUND(RAND()*((SELECT MAX(id)FROM `res` )-(SELECT MIN(id) FROM `res`))+(SELECT MIN(id) FROM `res`)) AS id )AS t2
WHERE t1.id>=t2.id ORDER BY t1.id LIMIT 1;
参考:http://blog.csdn.net/testcs_dn/article/details/10149293