order by random

  • Thread starter Christopher Brandsdal
  • Start date
C

Christopher Brandsdal

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
WHERE [whatever] ORDER BY [random]

How do I do this?


thanks Christopher Brandsdal
 
B

Bob Barrows [MVP]

Christopher said:
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
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
 
L

larrybud2002

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?
 
C

Christopher Brandsdal

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 said:
Christopher said:
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
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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top