Posted on 2008-07-03 23:08
追風舞者 閱讀(161)
評論(0) 編輯 收藏 所屬分類:
Database
1.MySQL
同時使用內置RAND函數、LIMIT函數和ORDER BY
select * from table
order by rand() limit 5
2.Oracle
同時使用DBMS_RANDOM包中的內置函數 VALUE、 ORDER BY和內置函數ROWNUM
select * from(
select name from table order by dbms_random.value()
) where rownum <=5