标签:
1.Mysql随机取数据,性能最好的方法:
用join取出一条
SELECT * FROM `table` AS t1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM `table`)) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id ASC LIMIT 5;
取出多条(最大值-最小值)* 随机数 +最小值
SELECT * FROM users WHERE userId >= ((SELECT MAX(userId) FROM users)-(SELECT MIN(userId) FROM users)) * RAND() + (SELECT MIN(userId) FROM users) LIMIT 1
做项目中遇到所有的常用知识点(javascript、php、mysql、apache、nginx)更新
标签:
原文地址:http://www.cnblogs.com/bc8web/p/5904489.html