tags:

views:

55

answers:

5

i am making a n application based on quiz therefore i need to select data randomly from database i m using sqlite please help

A: 
SELECT * FROM table ORDER BY RANDOM()
john_doe
+1  A: 

You should check RANDOM() function, ex:

SELECT * FROM table ORDER BY RANDOM() LIMIT 1;
Maciej Kucharz
thanks..........
Online
A: 
Select * from Table order by random()
Floyd
A: 

This seems to be a duplicate or at least related to this.

John
A: 

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