SQL SERVER: selecttop2*from pt_login orderbynewid() MY SQL: select*from tablename orderbyrand() limit 10 ORACLE: select*from (select*from t orderby dbms_random.value) where rownum<10; ACCESS: yourstr="*1*3*4*6*12*." sql="selecttop10* form yourdb where instr('*'&id&'*','"&yourstr&"')<>0
<% n=10''取任意10条记录 set rs = server.CreateObject ("adodb.recordset") sql ="select * from table" rs.open sql,conn,1,1 count=rs.recordcount ''记录总数 IF Count<>emptyThen Randomize for i =1to n ''循环n次 num=Fix(Rnd*count) ''num便是随机产生的记录行数,用Fix(),使其不会大于count值。 rs.move num ''移到改随机行 Response.write rs(0) ''出该条记录 rs.movefirst ''别忘了再把指针移到第一条 next EndIF rs.close set rs =nothing %>