+ -
当前位置:首页 → 问答吧 → access随机调取应该怎么编写

access随机调取应该怎么编写

时间:2011-07-22

来源:互联网

我知道php的随机是
SELECT * FROM wd_answer order by Rand() limit 5
那么asp呢,
我现有的代码是
select top 5 id,xxlid,xlname,dateandtime from news where xxlid=134 order by id desc
改成
select top 5 id,xxlid,xlname,dateandtime from news where xxlid=134 order By Rnd(-(ID+"&Rnd()&"))
后刷新很多次,有变化但很小,谁知道怎么修改呢?

作者: hgzz8023   发布时间: 2011-07-22

是随机排序吧,rnd()返回值为0-1的小数,变化范围当然很小,要进行必要的操作扩大随机范围,比如:
产生一个从A到B范围的随机整数:cint(A + rnd() * B)

另外,产生随机数之前最好用randomize timer设定初始种子数,否则每次随机数都是一样的顺序

[ 本帖最后由 woochysean 于 2011-7-26 02:22 编辑 ]

作者: woochysean   发布时间: 2011-07-26