Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > order by random

Reply
Thread Tools

order by random

 
 
Christopher Brandsdal
Guest
Posts: n/a
 
      01-12-2005
Hi!

I'm not sure, but this might be a question not right for this group.

Problem:
I have a sql statement that selects all rows with a sertain criteria, an
display it on a page.
What I need to do is to order these by random...

Is there any way to order by random?

example:

SELECT * FROM [table] WHERE [whatever] ORDER BY [random]

How do I do this?


thanks Christopher Brandsdal


 
Reply With Quote
 
 
 
 
Christopher Brandsdal
Guest
Posts: n/a
 
      01-12-2005
By the way... I'm using MS JScript



"Christopher Brandsdal" <(E-Mail Removed)> skrev i melding
news:eDS6MAK%(E-Mail Removed)...
> Hi!
>
> I'm not sure, but this might be a question not right for this group.
>
> Problem:
> I have a sql statement that selects all rows with a sertain criteria, an
> display it on a page.
> What I need to do is to order these by random...
>
> Is there any way to order by random?
>
> example:
>
> SELECT * FROM [table] WHERE [whatever] ORDER BY [random]
>
> How do I do this?
>
>
> thanks Christopher Brandsdal
>



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      01-12-2005
Christopher Brandsdal wrote:
> By the way... I'm using MS JScript
>
>

Irrelevant when asking about sql syntax.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      01-12-2005
Christopher Brandsdal wrote:
> Hi!
>
> I'm not sure, but this might be a question not right for this group.
>

..asp.db might have been more relevant than .asp.general, but no big deal in
this case.

> Problem:
> I have a sql statement that selects all rows with a sertain criteria,
> an display it on a page.
> What I need to do is to order these by random...
>
> Is there any way to order by random?
>
> example:
>
> SELECT * FROM [table] WHERE [whatever] ORDER BY [random]
>
> How do I do this?
>

Impossible to answer without knowing what database type and version you are
using, in addition to knowing what operating system your database is running
on in some cases.

For a general answer see:
http://www.aspfaq.com/show.asp?id=2132

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
larrybud2002@yahoo.com
Guest
Posts: n/a
 
      01-12-2005
> I'm not sure, but this might be a question not right for this group.
>
> Problem:
> I have a sql statement that selects all rows with a sertain criteria,

an
> display it on a page.
> What I need to do is to order these by random...
>
> Is there any way to order by random?


Let's try this posting business again

Few way you could do this. If the table ALWAYS should return a random
order when a select is done, you could build a trigger which populates
a "random" named column when the select is done with random values,
then do an order by random in the select statement

If you don't always want this, and performace is an issue, write a
stored procedure that populates the "random" named field, then do a
select on the table.
Curious: What application do you need this functionality?

 
Reply With Quote
 
Christopher Brandsdal
Guest
Posts: n/a
 
      01-13-2005
Thanks

I'm using access 2002 on win2k3

This is what I actually need to do:

I have a database that stores articles, and a asp page that displays all the
articles...
Every article has an ID. Now I can display the articles sorted alphabeticly,
by date or by a "orderID".
But I want to display it by ID in a random order...
Don't know if this makes sense hehe...




"Bob Barrows [MVP]" <(E-Mail Removed)> skrev i melding
news:uoogGfK%(E-Mail Removed)...
> Christopher Brandsdal wrote:
>> Hi!
>>
>> I'm not sure, but this might be a question not right for this group.
>>

> .asp.db might have been more relevant than .asp.general, but no big deal
> in this case.
>
>> Problem:
>> I have a sql statement that selects all rows with a sertain criteria,
>> an display it on a page.
>> What I need to do is to order these by random...
>>
>> Is there any way to order by random?
>>
>> example:
>>
>> SELECT * FROM [table] WHERE [whatever] ORDER BY [random]
>>
>> How do I do this?
>>

> Impossible to answer without knowing what database type and version you
> are using, in addition to knowing what operating system your database is
> running on in some cases.
>
> For a general answer see:
> http://www.aspfaq.com/show.asp?id=2132
>
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Random "The IListSource does not contain any datasources" and more (Crashing a live site at random, twice a week or so) Lars-Erik Aabech ASP .Net 8 04-28-2005 07:52 AM
Random not really random... Maziar Aflatoun ASP .Net 4 08-05-2004 01:26 AM
Random NOt random? Darren Clark ASP .Net 3 06-24-2004 05:23 PM



Advertisments