George Eric R Contr AFSPC/CVYZ writes:

> How about this:
> 
> Create a table with two columns.  The first is autoincrement, so guarenteed
> unique.  The second is random (but not neccesarily unique).
> 
> Now sort this table by the second column.
> The first column, read in order, should now suit your needs, but I don't
> think you can do inserts automatically using these values.

I can see one problem with this, which is that in the case that you
get two identical number in the second column their order will be
strongly dependent on the values in the first column. I suggest that
you generate this table using the normal procedure for randomizing
the order of a list, namely that you store the numbers 1 to N in
an array, pick a random element, insert it into the second column
of the table, move the last element of the array to the hole that
was created in the array, and repeat until the array is empty.

Then when you insert values into your own table, just use a regular
auto_increment id (after all, this id should carry no information,
except that it identifies a row), and when you want the rows in the
well-defined but randomized order, join with the two-column table
and sort on the random number.

//C - pondering quasi-random numbers

-- 
 Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280
 [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/
 Amiga user since '89, and damned proud of it too.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to