If you're using SQL Server, you can try:

SELECT    *, NewID()
FROM      tblWhatever
ORDER BY    NewID()

-Nelson


----- Original Message -----
From: "Keen" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, November 03, 2001 8:28 PM
Subject: Random Records


> I need to run a query and return 10 random records.  I used the following
to
> get the records but can have the same random number returned more than
once.
> I would like to insure that the 10 records returned are distinct.  Any
> suggestions?  TIA
>
> <cfloop from="1" to="10" index="i">
>   <cfset randomRecord = RandRange(1,tenants.RecordCount)>
>   <cfoutput>
>    #tenants.tenant_number[randomRecord]#
#tenants.last_name_1[randomRecord]#
> <br>
>   </cfoutput>
> </cfloop>
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to