Click to See Complete Forum and Search --> : ASP - Random values from database


cancer10
12-21-2006, 07:36 AM
Hello,

I have a question:

Suppose I have a table named as tblfriends and there are 3 columns with several row. Column names are: name, email, phone

I want to pick 5 names randomly from the table each time my asp page refreshes.


How can this be coded in classic asp?



Thanx for your help

lmf232s
12-21-2006, 04:06 PM
Well this answer is based on SQL Server. Im not sure if it works on any other DB or if there is something similar.

Use the ORDER BY NewId()

Example


SELECT Top 5 Name,
Email,
Phone
FROM MyTable
ORDER BY NewId()