从数据库表中随机获取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

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务