Try this :-)

Select Distinct(field) from tablename (Note: this is provided that the
field named is a PK. I think there is also another way to get just the
number of records.

Then when the query is returned you could then randomzie a number
between the 1 and then number returned then use a query to pull that
record out.




-----Original Message-----
From: Mark Leder [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, 1 January 2002 3:58 AM
To: CF-Talk
Subject: Retrieving Random Text

I having problems getting the following to work correctly.
1) The first query only pulls record IDs of a particular category, in
this
case category #3.
2) The output query randomizes the records IDs of that category.  When I
do
an output test after this there are a number of records, which proves to
me
that it works correctly.

3) The second query then matches the randomized ID with an id from the
db.
No matter what I do, the same record each time comes up when I rerun
this
routine.  Am I missing something?

Thanks,
Mark

<cfquery name="q_test" datasource="dbase">
SELECT t_ID FROM t_testmain WHERE ID_testcat = 3
</cfquery>

<cfoutput query="q_test">
<cfset Selecttest = #ListGetAt(t_ID, RandRange(1, ListLen(t_ID)))#>
</cfoutput>

<cfquery name="DisplayTest" datasource="dbase">
SELECT *
FROM t_testmain
WHERE t_ID = #Selecttest#
</cfquery>

<cfoutput>#trim(displaytest.quote)#</cfoutput>

______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
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