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
同時使用內置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