There is no Order By Random kind of clause if that's what you're asking. What exactly are you trying to do?
I didn't think there would be that kind of clause. I want to select the database and order it in a random order. I will only be displaying the first row on my homepage so that I can display an image which links to a full size version on another page.
Will you be displaying things in random order or just selecting the first record randomly? If selecting the first record randomly, by an id for example, just come up with a random number generator and select the one record using that random number.
Will you be displaying things in random order or just selecting the first record randomly? If selecting the first record randomly, by an id for example, just come up with a random number generator and select the one record using that random number.
What language are you using to code your page?
Im using VB
I would prefer not to do it that way because I have deleted records, so some IDs are missing.
I'm thinking off the top of my head here, but I think you could load all your records into an array, then randomly pick one record from the array for display.
I may be wrong but wouldn't this just be selecting a random number between certain values. So if I had deleted a record with ID of 8, then if 8 was randomly selected nothing would appear
<!---first set the query --->
<cfquery name="rs" datasource="#dsn#">
SELECT [column_names(s)]
FROM [table_name]
</cfquery>
<!--- then use the output to display randomly --->
<cfset displayRow = randRange(1,rs.recordcount)>
<cfoutput query="rs" startrow="#displayRow#" maxrows="1">
-- show the random record
</cfoutput>