Randomly Select a Row with SQL in Access

后端 未结 4 1010
梦毁少年i
梦毁少年i 2020-12-22 00:27

I have a small access database with some tables. I am trying the code in the sql design within access. I just want to randomly select a record within a table.

I cre

4条回答
  •  有刺的猬
    2020-12-22 01:08

    You need both a variable and a time seed to not get the same sequence(s) each time you open Access and run the query - and to use Access SQL in Access:

    SELECT TOP 1 Abbreviation
    FROM STATEABBREVIATION
    ORDER BY Rnd(-Timer()*[ID]);
    

    where ID is the primary key of the table.

提交回复
热议问题