mysql随机查询

   来源:无忧图库  发布时间:2011-06-21    浏览:1次    [收藏该代码]

mysql随机查询

SELECT * FROM `table`  
WHERE id >= (SELECT floor( RAND() * ((SELECT MAX(id) FROM `table`)-(SELECT MIN(id) FROM `table`)) + (SELECT MIN(id) FROM `table`)))   
ORDER BY id LIMIT 1;  
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;  

顶一下
(0)
50.00%
踩一下
(0)
50.00%
+ 分享连接

↑上一篇:没有了
↓下一篇:没有了


推荐文章更多››
热门文章更多››

关于我们 - 版权声明 - 广告服务 - 无忧论坛 - 工作机会 - 联系我们 - 在线留言

Copyright © 2010-2011 5utu.com All Rights Reserved.

豫ICP备10020617号