新微赢技术网
标题:
[小 弟 跪 求]如何随机取出记录并同时满足某条件?
[打印本页]
作者:
Rain
时间:
2010-1-18 04:18
标题:
[小 弟 跪 求]如何随机取出记录并同时满足某条件?
如何取出某数据库随机一记录,并且要满足该记录字段1必须<10,这怎么做?
作者:
tp寶寶^ō^
时间:
2010-1-18 04:18
dim min,sql,rs,rndID,i
minValue = 10
Randomize
sql = "Select * FROM table1 WHERE col1<"&minValue
Set rs = server.createobject("ADODB.RecordSet")
rs.Open sql,dbc,adOpenForwardOnly,adLockReadOnly
If rs.Eof Then
rs.Close
Set rs = Nothing
'show error, or donothing
End If
rndID = int(rnd*rs.RecordCount)
for i=0 to rndID - 1
rs.MoveNext
next
'now it is the random position, get data from rs
'do somthing you want
rs.Close
Set rs = Nothing
作者:
秋风扫落叶
时间:
2010-1-18 04:18
疯狂谢谢!
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2