Without modifying the query, here is one way. <cfquery name="queryName" dsn="#dsn#"> SELECT Col1, Col2, Col3 .. </cfquery>
<cfset randRecordsList = ''> <cfloop from="1" to="4" index="i"> <cfset randVal = randRange(1,queryName.recordCount)> <cfset randRecordsList = listAppend(randRecordsList , randVal)> </cfloop> <cfloop list="#randRecordsList#" index="i"> <cfoutput> #queryName.col1[i]# #queryName.col2[i]# #queryName.col3[i]#<br> </cfoutput> </cfloop> There is probably a better way, but this will work. The routine doesn't need to know that you have 88 records coming back, since you can use the queryName.recordcount property to get that, and wont break if a different amount of records is returned. This example also demonstrates how to access a query resultset as a structure of arrays. You may want to add a little additional bit of code in the first loop to make sure no duplicate random numbers get chosen though. jon ----- Original Message ----- From: "Brian Simpson" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Saturday, May 18, 2002 9:27 AM Subject: Random display of QUERY results > I'm still new to Cold Fusion and need some help. > > How do you Randomly display 4 results out of a query? > > I have a query that selects 88 records out of 486. I want to display 4 of > these record at Random. > > Thanks > > > ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists