主流数据库随机读取N条数据的方法
2012/3/20 15:45:27 类别:数据库摘要:MSSQL,MYSQL,ACCESS中读取随机数据方法
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
mysql中随机读取数据库记录 ——————————————————————————- Select * from tablename order by rand() limit 10 sqlserver中随机读取数据库记录 ——————————————————————————– select top 10 * from tablename order by NEWID() Access中随机读取数据库记录 ——————————————————————————- Select top 10 * FROM tablename orDER BY Rnd(PId) PId:为你当前表的ID字段名