Might be simplest just to query to count the records

SELECT COUNT(id) as total
FROM customers

Then use cf to determine the randomness:

<cfset thewinner = RandRange(1,query.total)>

SELECT *
FROM customers
WHERE id = <cfqueryparam value="#Val(thewinner)#"
cfsqltype="CF_SQL_INTEGER">


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

-----Original Message-----
From: Rob Wilkerson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 29, 2006 3:10 PM
To: CF-Talk
Subject: Re: Pulling a random record from the DB


I should mention that the latter option - returning everything just to
use one - can have a big performance impact, so be careful with that
one.

On 3/29/06, Rob Wilkerson <[EMAIL PROTECTED]> wrote:
> Not so easy, then.  Try Google-ing "ms access random record" and
> you'll get a lot of info about creating seeds, etc.  You can go that
> direction or return all and select a random record using randRange (
> 1, queryName.recordcount ).
>
> Again, that's from memory, so you might have to play with it a bit.
>
> On 3/29/06, Will Tomlinson <[EMAIL PROTECTED]> wrote:
> > > What DB?  With SQL Server 2K, I think the following will work
> > > (untested - going straight from distant memory):
> >
> > I'm sorry - it's Access.
> >
> > Thanks,
> > Will
> >
> >



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:236465
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to