Forum Moderators: open
HTH
Function RandomNumber(intHighestNumber )
Randomize
RandomNumber = Int(Rnd * intHighestNumber)+1
End Function
strProductList=""
' get all id's
set objRS=objConn.Execute ("SELECT ID FROM PRODUCTS")
myArr = objRS.GetRows()
for i=1 to 3
strProductList = strProductList & cstr( myArr(0,RandomNumber( ubound(myArr,2)) )) & ", "
next
strProductList=left(strProductList,len(strProductList)-1)
' get the 3 random ads
strSQL = "SELECT * FROM Products WHERE Products.ID IN ("& strProductList &")"
select * from mytable order by random() limit 10;
replace random() and 10 with the name of the function and the number of records you need.
But it would take a lot of time to execute on really large tables.