Possible Duplicate:
How to get random record from MS Access database
In my project I have gone through a scenario, where i have to retrieve records from MS Access table RANDOMLY. What query should I use to retrieve the records in a random base??
Possible Duplicate:
How to get random record from MS Access database
In my project I have gone through a scenario, where i have to retrieve records from MS Access table RANDOMLY. What query should I use to retrieve the records in a random base??
Assuming that in a table MyTable
you have a primary key ID
field in a that is an autoincrement integer, you can do something like this to retrieve, say 10 random records from MyTable
:
SELECT Top 10 *
FROM (SELECT *,
Rnd(ID) AS RandomValue
FROM MyTable)
ORDER BY RandomValue
Edit:
Found another similar answer: How to get random record from MS Access database