954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ASP - Random values from database

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

cancer10
Posting Whiz in Training
234 posts since Dec 2004
Reputation Points: 58
Solved Threads: 1
 

use this as your query
SELECT TOP 5 name FROM tblfriends
ORDER BY NEWID()

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

Random:

SQL Server:
SELECT TOP 5 name FROM tblfriends
ORDER BY RAND()

MySQL:
SELECT name FROM tblfriends
ORDER BY RANDOM() LIMIT 5

nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You