1.MySQL
同時(shí)使用內(nèi)置RAND函數(shù)、LIMIT函數(shù)和ORDER BY
select * from table
order by rand() limit 5
2.Oracle
同時(shí)使用DBMS_RANDOM包中的內(nèi)置函數(shù) VALUE、 ORDER BY和內(nèi)置函數(shù)ROWNUM
select * from(
select name from table order by dbms_random.value()
) where rownum <=5
同時(shí)使用內(nèi)置RAND函數(shù)、LIMIT函數(shù)和ORDER BY
select * from table
order by rand() limit 5
2.Oracle
同時(shí)使用DBMS_RANDOM包中的內(nèi)置函數(shù) VALUE、 ORDER BY和內(nèi)置函數(shù)ROWNUM
select * from(
select name from table order by dbms_random.value()
) where rownum <=5