[thelist] CF - Random Rows?

Frank framar at interlog.com
Fri Aug 18 14:55:10 CDT 2000


I'm trying to create the situation whereby I can access a random 
record from the lot. I had originally used max and min, but if a 
record is deleted from the set, and the random number turns out to be 
the ID of the deleted record, there's a problem.

Now, as I've got it set up (see below) I'm getting that there are too 
few parameters. Why isn't Int(GetExisting.ID) seen as a legitimate 
int? Does anyone know the work around?



<!--- Choose all existing records --->
<cfquery name="GetExisting" datasource="#datasource#">
   SELECT ID
    FROM Address
</cfquery>


<!--- Select a random property from the existing records--->
<cfquery name="GetRand" datasource="#datasource#">
    SELECT MAX(Int(GetExisting.ID)) as MaxProp,
           MIN(Int(GetExisting.ID)) as MinProp
    FROM Address
</cfquery>



<cfoutput query="GetRand">
    #RandRange(MinProp, MaxProp)#
</cfoutput>
-- 


Frank Marion                      Loofah Communications
frank at loofahcom.com               http://www.loofahcom.com





More information about the thelist mailing list