1. 程式人生 > >從資料庫表中隨機獲取N條記錄的SQL語句

從資料庫表中隨機獲取N條記錄的SQL語句

Oracle:

       select * from (select * from tableName order by dbms_random.value) where rownum < N;


MS SQLServer:

       select top N * from tableName order by newid();

 

My SQL:

       

select * from tableName order by rand() limit N;



轉自:http://blog.csdn.net/senton/article/details/4404101