On 1/25/07, P Kishor <[EMAIL PROTECTED]> wrote:

1. given a non-sequential id, select all the ids
2. grab a random id
3. select the row with that id.

is there a better way of accomplishing this, one that requires a
single round-trip to the db?


There's always the random shuffle method.
add a column to the table called 'sortorder'
assign a random number to that column each time you want the list reordered.
Then use
Select * from mytable order by sortorder limit 1
That method is useful where you need a specific list in random order, like
for card shuffles.
If you use a hash you usually get repeats of some elements and some left
out.

Reply via email to