Home  >  Article  >  Database  >  随机提取N条记录

随机提取N条记录

WBOY
WBOYOriginal
2016-06-07 18:06:49850browse

随机提取N条记录

随机提取10条记录的例子:
Sql server:

select top 10 * from 表 order by newid()

Access:

SELECT top 10 * FROM 表 ORDER BY Rnd(id)

Rnd(id) 其中的id是自动编号字段,可以利用其他任何数值来完成

比如用姓名字段(UserName)

SELECT top 10 * FROM 表 ORDER BY Rnd(len(UserName))

MySql:

Select * From 表 Order By rand() Limit 10
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn