随机提取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

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3