473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

order by random

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
5 2201
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
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
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
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jefferis NoSpamme | last post by:
I have a query that is showing new items in a store based upon their inventory date. The problem with my Random order sort is that when the "next" link is pressed, the random function is called...
4
by: Frank & Janny Plaza | last post by:
I am trying to write a program in which the users will each enter their names and when all names have been entered, I want to randomly sort this list of names several times and then show the order in...
7
by: Jean-Francois.Doyon | last post by:
Hello, I'm trying to retrieve a limited number of random rows, and order them by a column, and am not having any luck with that last part: SELECT * FROM tablename ORDER BY random(), id LIMIT...
5
by: javier garcia - CEBAS | last post by:
Hi, I'm not an expert, not by far. I've just installed postgres7.4 and have realized tat the order of rows in queries in different to that in 7.3.4. It seems that previously it was more logic,...
5
by: Greg Brady | last post by:
Is there a way to return a random sort order from a query?
22
by: Nhmiller | last post by:
Is there a way to do this? Thanks. Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
6
by: InnoCreate | last post by:
Hi everyone. I've recently written a classic asp website which uses an MS Access datasource. I know this is less than an ideal data source as it has limited functionality. I have a search form on...
9
by: Tuxedo | last post by:
I'd like to reorganize the third, fourth, fifth and sixth, as well as any elements thereafter in an array in random order: var a = new...
2
by: federicog | last post by:
I have to create a listing in random order from a few mysql tables. I can't use ORDER BY RAND() for a few reasons: - The random order has to change only every 24hs, ie: today it will show rows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.