sql随机抽取数据库记录

Mysql:select * from [tablename] order by rand() limit 10 

Sql Server:select top 5 * from [tablename] order by NEWID() 

Access:select top 5 * from [tablename] order by rnd(id),其中id是自动编号的字段。在vb+access可以随机,但在asp里却没法得到随机的结果。可能是asp有缓存的结果吧,因此,需要修改一下这条语句,改为下面的方式: 
   randomize
    select top 5 * from [tablename] order by rnd(-(id+rnd()))
posted @ 2010-08-12 10:40  PPDev  阅读(2901)  评论(0编辑  收藏  举报