Scenario:
Whole number addition questions in number 1000 are generated randomly and inserted into column question with unique constraint of postgresql table questions, around 150 questions duplicate for which insertions fail and their sequence numbers are wasted.
Requirement:
When user takes test 50 unique questions has to be selected.
I tried in php as follows:
$qid=mt_rand(1, 1000);
$dmq="SELECT * FROM questions WHERE qstn_id =". $qid;
But, I am getting a) skipped question_id or b) duplicate question_ids.
Please guide me in selecting 50 unique questions randomly from the table.