i am making a n application based on quiz therefore i need to select data randomly from database i m using sqlite please help
Asked
Active
Viewed 264 times
-1
-
1You haven't specified it, but probably you also want to ensure that you don't get the same question twice in a row. – Mark Byers Aug 05 '10 at 09:37
4 Answers
1
You should check RANDOM() function, ex:
SELECT * FROM table ORDER BY RANDOM() LIMIT 1;

Maciej Kucharz
- 1,395
- 1
- 13
- 17
0
To minimise hits on the database, I would suggest reading out all of your questions into a data structure in memory (assuming there's not so many that it would consume all memory).
You could then shuffle the array using a decent shuffle algorithm and pop questions from the array to use.

Jasarien
- 58,279
- 31
- 157
- 188