By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,401 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,401 IT Pros & Developers. It's quick & easy.

order by random

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
By the way... I'm using MS JScript

"Christopher Brandsdal" <br*******@binaer.no> skrev i melding
news:eD****************@TK2MSFTNGP10.phx.gbl...
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

Jul 22 '05 #2

P: n/a
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"
Jul 22 '05 #3

P: n/a
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"
Jul 22 '05 #4

P: n/a
> 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?

Jul 22 '05 #5

P: n/a
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]" <re******@NOyahoo.SPAMcom> skrev i melding
news:uo****************@TK2MSFTNGP09.phx.gbl...
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"

Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.