You didn't specfically say your db so here's how to do it in mySQL.

SELECT id
FROM customers
ORDER BY RAND()
LIMIT 1

That will give you one random record.

<!----------------//------
andy matthews
web developer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->

-----Original Message-----
From: Will Tomlinson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 29, 2006 1:54 PM
To: CF-Talk
Subject: Pulling a random record from the DB


I need to pull a random record from an autonumber field. It's for a prize
for the lucky winner. :)

I'd thought about creating a ValueList() from the ID field, but then got
stuck in my thinking. What's the best way to accomplish this?

Thanks,
Will



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:236464
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to