Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-18-2006, 12:23 AM   PM User | #1
CurtWRC
Regular Coder

 
CurtWRC's Avatar
 
Join Date: May 2005
Location: UK
Posts: 224
Thanks: 9
Thanked 1 Time in 1 Post
CurtWRC is an unknown quantity at this point
ORDER by random

Is there a way of ordering a selected database randomly?
If so does anyone know the string I would have to use for this?

Thanks.
__________________
http://curtdotnet.blogspot.com/
CurtWRC is offline   Reply With Quote
Old 02-18-2006, 02:08 AM   PM User | #2
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,053
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
There is no Order By Random kind of clause if that's what you're asking. What exactly are you trying to do?
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Old 02-18-2006, 10:26 AM   PM User | #3
CurtWRC
Regular Coder

 
CurtWRC's Avatar
 
Join Date: May 2005
Location: UK
Posts: 224
Thanks: 9
Thanked 1 Time in 1 Post
CurtWRC is an unknown quantity at this point
Quote:
Originally Posted by vinyl-junkie
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.

Thanks.
__________________
http://curtdotnet.blogspot.com/
CurtWRC is offline   Reply With Quote
Old 02-18-2006, 03:32 PM   PM User | #4
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,053
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
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?
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Old 02-18-2006, 05:50 PM   PM User | #5
CurtWRC
Regular Coder

 
CurtWRC's Avatar
 
Join Date: May 2005
Location: UK
Posts: 224
Thanks: 9
Thanked 1 Time in 1 Post
CurtWRC is an unknown quantity at this point
Quote:
Originally Posted by vinyl-junkie
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.
__________________
http://curtdotnet.blogspot.com/
CurtWRC is offline   Reply With Quote
Old 02-18-2006, 06:07 PM   PM User | #6
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,053
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
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.
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Old 02-20-2006, 08:51 PM   PM User | #7
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Are you using access? If so, have a look at the Rnd() function.

Good luck;
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 03-01-2006, 04:39 PM   PM User | #8
CurtWRC
Regular Coder

 
CurtWRC's Avatar
 
Join Date: May 2005
Location: UK
Posts: 224
Thanks: 9
Thanked 1 Time in 1 Post
CurtWRC is an unknown quantity at this point
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
__________________
http://curtdotnet.blogspot.com/
CurtWRC is offline   Reply With Quote
Old 12-05-2006, 06:11 PM   PM User | #9
luckycharm
New to the CF scene

 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
luckycharm is an unknown quantity at this point
Selecting a random record from an Access databse

I'm assuming your using coldfusion. So if you are, his might be usefull:

________________________________________________________________

<!---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>



Hope this helps.
luckycharm is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:47 PM.


Advertisement
Log in to turn off these ads.