order by random

Discussion in 'ASP General' started by Christopher Brandsdal, Jan 12, 2005.

  1. 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
     
    Christopher Brandsdal, Jan 12, 2005
    #1
    1. Advertising

  2. By the way... I'm using MS JScript



    "Christopher Brandsdal" <> skrev i melding
    news:eDS6MAK%...
    > 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
    >
     
    Christopher Brandsdal, Jan 12, 2005
    #2
    1. Advertising

  3. 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"
     
    Bob Barrows [MVP], Jan 12, 2005
    #3
  4. 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"
     
    Bob Barrows [MVP], Jan 12, 2005
    #4
  5. Christopher Brandsdal

    Guest

    > 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?
     
    , Jan 12, 2005
    #5
  6. 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]" <> skrev i melding
    news:uoogGfK%...
    > 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"
    >
     
    Christopher Brandsdal, Jan 13, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren Clark

    Random NOt random?

    Darren Clark, Jun 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    459
    mikeb
    Jun 24, 2004
  2. Maziar Aflatoun

    Random not really random...

    Maziar Aflatoun, Aug 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    26,711
    Maziar Aflatoun
    Aug 5, 2004
  3. Lars-Erik Aabech
    Replies:
    8
    Views:
    845
    Lars-Erik Aabech
    Apr 28, 2005
  4. globalrev
    Replies:
    4
    Views:
    771
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,175
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page