He said it was an autonumber type. Access is the only one I can think of
that uses it.

You could get all the ids and use listgetat(valuelist(myq,id), randrange(1,
myq.recordcount)) to pick a random ID from the list.... then query with that
ID.

-or- write a function in access to do it (ewww)
http://support.microsoft.com/?kbid=210468


..:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com

 

 

-----Original Message-----
From: Andy Matthews [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 29, 2006 4:18 PM
To: CF-Talk
Subject: RE: Pulling a random record from the DB

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:236472
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