mysql随机查询一条数据

SELECT *   
FROM `s_history` AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM `s_history`)-(SELECT MIN(id) FROM `s_history`))+(SELECT MIN(id) FROM `s_history`)) AS id) AS t2   
WHERE t1.id >= t2.id   
ORDER BY t1.id LIMIT 1;



猜你喜欢

转载自blog.csdn.net/zhangchb/article/details/80336178