Oct 24, 2005 #1 elvanace1 MIS Sep 26, 2005 32 US Is is possible to write a query that will select records from a table randomly?
Oct 24, 2005 #2 PHV MIS Nov 8, 2002 53,708 FR Have a look at the Rnd function. Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886 Upvote 0 Downvote
Have a look at the Rnd function. Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
Oct 24, 2005 Thread starter #3 elvanace1 MIS Sep 26, 2005 32 US Rnd() generates a random number, but what if the table's index is alpha-numneric. How do you get a random record? Upvote 0 Downvote
Rnd() generates a random number, but what if the table's index is alpha-numneric. How do you get a random record?
Oct 24, 2005 #4 PHV MIS Nov 8, 2002 53,708 FR One way: SELECT TOP 1 ... ORDER BY Rnd([Any numeric field]) Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886 Upvote 0 Downvote
One way: SELECT TOP 1 ... ORDER BY Rnd([Any numeric field]) Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
Oct 24, 2005 Thread starter #5 elvanace1 MIS Sep 26, 2005 32 US But if there is no purely numeric field, what then? Upvote 0 Downvote
Oct 24, 2005 #6 alvechurchdata Programmer Nov 8, 2003 1,737 GB But if there is no purely numeric field, what then? Click to expand... Easiest answer might be to add a numeric field to the table. Another option would be to use Asc() on several characters of a character field or Cdbl() on a date field. Or you could use DAO and do a MoveFirst() followed by a lot of random calls to Move() Geoff Franklin http://www.alvechurchdata.co.uk Upvote 0 Downvote
But if there is no purely numeric field, what then? Click to expand... Easiest answer might be to add a numeric field to the table. Another option would be to use Asc() on several characters of a character field or Cdbl() on a date field. Or you could use DAO and do a MoveFirst() followed by a lot of random calls to Move() Geoff Franklin http://www.alvechurchdata.co.uk
Oct 24, 2005 #7 PHV MIS Nov 8, 2002 53,708 FR SELECT TOP 1 ... ORDER BY Rnd(Val([Any field])) Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886 Upvote 0 Downvote
SELECT TOP 1 ... ORDER BY Rnd(Val([Any field])) Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
Oct 24, 2005 Thread starter #8 elvanace1 MIS Sep 26, 2005 32 US SELECT TOP 1 ... ORDER BY Rnd(Val([Any field])" is perfect! Thanks sooo much. Upvote 0 Downvote