You can probably do this in many ways, but the trick will be to keep the
amount of calls to the database to a minimum.  With that in mind, here's a
first try . . . 

<!--- all rows in oracle tables have a 'rowid' field --->
<cfquery name="get_all_ids" . . . >
select  rowid
from            sometable
</cfquery>

<!--- now choose the random numbers between 1 and get_all_ids.recordcount
--->
.... umm, you can look this up . . . 

<!--- now use the random numbers to get your three records --->
<cfquery name="get_rand_records" . . . >
select  field1, field2
from            sometable
where           rowid in ('#get_all_ids.rowid[randomnumber1]#',
'#get_all_ids.rowid[randomnumber2]#',
                                '#get_all_ids.rowid[randomnumber3]#')
</cfquery>

Dan

-----Original Message-----
From: Brandon Behrens [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 04, 2000 10:10 AM
To: [EMAIL PROTECTED]
Subject: OT: Selecting records at random in Oracle


Hello all,

I don't know if this is possible but I was wondering if there was a way to
tell oracle (using cold fusion) that I wanted 3 records, but I didn't care
which ones they were.  I guess a good analogy would be you load up a page
and you want to display a banner ad, but you don't care which banner ad you
display.  Any help would be appreciated.

Thanks in advance,

Brandon Behrens

Brandon Behrens
The Internet Design Firm
512.451.5225
[EMAIL PROTECTED]
http://www.theidf.com



----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to