Jump to content

random record


muhammadadilmalik

Recommended Posts

how we can get random record where the no. of record is variable. i am using the database "MS Access"thanx

Select an additional field with a random value in it. Use your unique identifier, which I presume you've called ID, as the seed:
SELECT Rnd(Table1.ID) as Bunny, * From Table1 ORDER BY Bunny;

If you execute a query in forward-only, read only mode, this should work just fine, otherwise you might have some unusual behavior. If you are run this query in one of the dynamic modes and try to sort, then a new set of random values will be generated, and the old ones will be erased (and so will your old ORDER BY).

Link to comment
Share on other sites

Select an additional field with a random value in it. Use your unique identifier, which I presume you've called ID, as the seed:
SELECT Rnd(Table1.ID) as Bunny, * From Table1 ORDER BY Bunny;

If you execute a query in forward-only, read only mode, this should work just fine, otherwise you might have some unusual behavior. If you are run this query in one of the dynamic modes and try to sort, then a new set of random values will be generated, and the old ones will be erased (and so will your old ORDER BY).

my dear thanx for your replyi have try this query but here is a problem. i am making a system that will generate random question and every time unique set of question. please chek this query it will generate every time same set of values
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...