locked
Order By NEWID() in access RRS feed

  • Question

  • User-706647060 posted

    in access database, can we use NEWID() for order by to make a rondom selections ! I tried but I failed. Is there any other way ?

    Sunday, May 30, 2010 8:02 AM

Answers

  • User-1199946673 posted

    I dont think i understand well your post, but you cannot be able to use any autonumubering technique in your order by clause, an it will never be part of your select statement. If you want make a random select statemnt based on what you already have in your tables use this:ç

     

    1. 1. SELECT TOP n * FROM [MyTable]     
    2. 2. ORDER BY Rnd([ID])    
       1. SELECT TOP n * FROM [MyTable]  
       2. ORDER BY Rnd([ID])  

     


    Hope this helps.

     

    No, it doesn't help! Althought this will work in the Access environment, when using Access in a web environment, this will return a random record, but it will return the same record over and over again!

    The solution is a little bit more complicated, see an earlier post I made:

    http://forums.asp.net/t/1158634.aspx#1910539

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 30, 2010 12:47 PM

All replies

  • User-388614333 posted

    I dont think i understand well your post, but you cannot be able to use any autonumubering technique in your order by clause, an it will never be part of your select statement. If you want make a random select statemnt based on what you already have in your tables use this:ç

       1. SELECT TOP n * FROM [MyTable]  
       2. ORDER BY Rnd([ID])  


    Hope this helps.


    Sunday, May 30, 2010 11:21 AM
  • User-1199946673 posted

    I dont think i understand well your post, but you cannot be able to use any autonumubering technique in your order by clause, an it will never be part of your select statement. If you want make a random select statemnt based on what you already have in your tables use this:ç

     

    1. 1. SELECT TOP n * FROM [MyTable]     
    2. 2. ORDER BY Rnd([ID])    
       1. SELECT TOP n * FROM [MyTable]  
       2. ORDER BY Rnd([ID])  

     


    Hope this helps.

     

    No, it doesn't help! Althought this will work in the Access environment, when using Access in a web environment, this will return a random record, but it will return the same record over and over again!

    The solution is a little bit more complicated, see an earlier post I made:

    http://forums.asp.net/t/1158634.aspx#1910539

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 30, 2010 12:47 PM
  • User-388614333 posted

    No, it doesn't help!

    I'm really sorry for that. Thanks for the clarify hans_v.

    Lio.

    Sunday, May 30, 2010 3:27 PM