民工的职业生涯
如果生命,没有遗憾,没有波浪……

mysql 随机取数据

SELECT t1.id as id,title,content,class_name,class_id,hits 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;  

posted on 2009-07-11 01:26  sharmy  阅读(204)  评论(0编辑  收藏  举报