[thelist] Random, Not the same Random twice

Ken Schaefer ken at adOpenStatic.com
Sat Mar 20 19:03:30 CST 2004


Are you retrieving random records from a database? Why don't you use an SQL
Statement that allows you to select the top 3 records from a randomly
ordered resultset?

www.adopenstatic.com/faq/randomrecord.asp has SQL statements for Access and
SQL Server. I'm sure similar can be accomplished in other databases.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Russ" <russ at unrealisticexpectations.com>
Subject: RE: [thelist] Random, Not the same Random twice


: Good advice; I ended up using CFLOOP to make it work out right.
:
: I'm not sure it's the most efficient, but it's only choosing from around
: 20 or so records.
:
: Thanks!
:
: Russ
:
: > -----Original Message-----
: > From: thelist-bounces at lists.evolt.org
: > [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Adrian Gonzales
: > Sent: Saturday, March 20, 2004 12:35 PM
: > To: thelist at lists.evolt.org
: > Subject: RE: [thelist] Random, Not the same Random twice
: >
: >
: > You could loop the cfif statement. Then if it isnt true, than
: > it breaks
: > the loop.
: >
: > Oh.. And just so you know... All those pound signs are not
: > neccesary in
: > the cfif statements.
: >
: >
: > Adrian Gonzales Jr.
: > Creative Director
: > Clear Span Media
: > clearspanmedia.com
: >
: >
: > -----Original Message-----
: > From: thelist-bounces at lists.evolt.org
: > [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Russ
: > Sent: Saturday, March 20, 2004 12:27 PM
: > To: thelist at lists.evolt.org
: > Subject: RE: [thelist] Random, Not the same Random twice
: >
: >
: > I've attempted a couple of things, one being DeleteClientVariable, and
: > that's not working.
: >
: > In the interim, I've basically built a CFIF that says if Story1 IS
: > Story2, get a new random number, but that only repeats itself
: > once.  The
: > success ratio is dramatically higher, but it's still not what I need.
: >
: > Is there an easier way to this? Certainly it's just my lack of
: > experience that's causing me issue here!  I hope!
: >
: > > find the fonction in Cold Fusion that allows you to delete
: > a record,
: > > here's a pseudo code : <CFSET Story1 =
: > > #RandRange(1,Stories.recordCount +1)#> <CFSET
: > > Stories.DeleteRecordByValue(Story1) > <CFSET Story2 =
: > > #RandRange(1,Stories.recordCount +1)#> <CFSET
: > > Stories.DeleteRecordByValue(Story2) > <CFSET Story3 =
: > > #RandRange(1,Stories.recordCount +1)#>
: > >
: > > each time you select a random value, you delete it from your array
: > > Stories.
: > >
: > >
: > > -----Original Message-----
: > > And it works great, but I can--and do--get duplicates.  I'm
: > searching
: > > for a resource to disallow Story2 and Story3 from getting the same
: > > variable as Story1, but I'm drawing a blank.
: > >
: > > Can someone point me in the right direction?



More information about the thelist mailing list