头像

数据库中抽取n条随机记录

随机取出n条记录:
Sql server:select top n * from 表 order by newid()
Access:Select top n * FROM 表 orDER BY Rnd(id)
mysql:Select * From 表 order By rand() Limit n
select * from youtab where mod ( rowid , 3 ) = 0
建议把MSSQL的联机丛书中的 Transact-SQL 参考大致看一遍,很多东西就心中有数了

——————————————————————————-
select * from tablename order by rand() limit 10
mysql中随机提取数据库记录
——————————————————————————–
select top 10 * from tablename order by NEWID()
sqlserver中随机提取数据库记录

——————————————————————————-
SELECT top 10 * FROM tablename ORDER BY Rnd(FId)
FId:为你当前表的ID字段名

Access中随机提取数据库记录