Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get random record from MS Access database

I have a MS access database. In that, one table consists of questions and answers with primary key questionID. I need to retrieve random question from that table using questionID. What keywords or query should I use for this scenario.

like image 444
user1169809 Avatar asked Mar 30 '12 04:03

user1169809


People also ask

How do I extract data from Access database?

To export data from Access, first select the table or other database object to export in the Navigation Pane. Then click the “External Data” tab in the Ribbon. Then click the button in the “Export” button group for the file format to which to export the object.


1 Answers

To get different random record you can use, which would require a ID field in your table

SELECT TOP 1 questionID FROM questions ORDER BY Rnd(-(100000*questionID)*Time())

A negative value passed as parameter to the Rnd-function will deliver the first random value from the generator using this parameter as start value. (A kind of defined randomize). Special thanks to @kobik 's hint from the comments.

like image 197
bummi Avatar answered Oct 03 '22 02:10

bummi