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