Click here to Skip to main content
15,886,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i have reiremetid, questions in my database ,how we pick 5 questions randomly from database based on requirement id
Posted
Comments
[no name] 13-Aug-12 9:54am    
The Random function usually works pretty well.
Kenneth Haugland 13-Aug-12 10:00am    
Dont repost your question, use the Improve quetion if you have additional inforamtion :)

I can give you one idea.
First,you need to randomly generate 5 requirement id from your code within your requirement id values of your database(it would be good if they are serial numbers).
Second,then you can easily select corresponding 5 questions according to their reiremetid.
The most important part here for you to create 5 random id and other part should be easier enough after first one.
 
Share this answer
 
For sql server this is it:
SQL
SELECT TOP 5 column FROM table
ORDER BY NEWID()


For other databases have a look at this :
http://www.petefreitag.com/item/466.cfm[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900