At 11:29 PM 4/8/02 +0200, you wrote: >Eric J Hoffman wrote: > > What is the best way to get a random record from an table that has > > frequent changes and updates...best practices or practical advice from > > veterans? Randrange between 1 and recordcount won't work pulling a num > > and then going against primary id..so somehow to get a "row"? > >Depends on your database. In PostgreSQL I prefer to use: >SELECT * >FROM table >ORDER BY Random() >LIMIT 1 >But in most other databases this doesn't work so I get the entire table >and then use the RandRange() trick to show just 1 column.
By the way, the RandRange() trick he was referring to works this way: #queryname.fieldname[randomnumber]# will spit out the record with row number = randomnumber. I think that's the place where Eric was confused about that method. Now available in a San Francisco Bay Area near you! http://www.blivit.org/mr_urc/index.cfm http://www.blivit.org/mr_urc/resume.cfm ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm 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

