Home > Database > Mysql Tutorial > 随机提取N条记录

随机提取N条记录

WBOY
Release: 2016-06-07 18:06:49
Original
910 people have browsed it

随机提取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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template