Hi Mark, howzit going? ;-)

Actually, I think your method (choosing a random number between 1 and MaxID,
then going  for the first record >= MaxID) could lead to some very
non-random behaviour when you have large gaps in your IDs.  The first ID
after a large gap will be heavily over-used.

I still like my method, sent before.  Should actually be random (within
limits of RandRange() function).

Watcha reckon?

Lee (Bjork) Borkman
http://bjork.net ColdFusion Tags by Bjork




-----Original Message-----
From: Warrick, Mark [mailto:[EMAIL PROTECTED]]


....

<!--- get the max record id from the table --->

<cfquery name="max" datasource="#session.dsn#">
SELECT max (CONTACT_ID) as maxid
FROM CONTACTS
</cfquery>

<!--- set a random number --->

<cfset randnum = RandRange(1,max.maxid)>

<!--- Then select the a record where the recordid equal to or greater than
the random number. --->

<cfquery name="random_record" datasource="#session.dsn#">
SELECT MIN (CONTACT_ID) as random_record
FROM contacts
where CONTACT_ID >= #randnum#
</cfquery>

<cfoutput query="random_record">
#random_record#
</cfoutput>



IMPORTANT NOTICE:
This e-mail and any attachment to it is intended only to be read or used by
the named addressee.  It is confidential and may contain legally privileged
information.  No confidentiality or privilege is waived or lost by any
mistaken transmission to you.  If you receive this e-mail in error, please
immediately delete it from your system and notify the sender.  You must not
disclose, copy or use any part of this e-mail if you are not the intended
recipient.  The RTA is not responsible for any unauthorised alterations to
this e-mail or attachment to it.  

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to