ITeye博客

从数据库表中随机获取N条记录的SQL语句

senton · 2009-08-03 14:24 · Database · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。