>> I'm not sure what the problem with this is?  The first (unique) column is
>> independent of the second (random) column.  If the random column has
>> duplicate values, it just means that the corrosponding first column
values
>> will be adjacent in the sorted table.

>If you're really depending on the randomness, this would be a bad
>thing. I don't suppose what it was going to be used for was something
>as sensitive as an Ising model simulation, so it's probably not a
>big deal. And besides, the random munber generator used in MySQL
>is probably platform specific and not guaranteed to be good enough
>for something like that.

The fact that the original poster is asking for unique random values is kind
of an oxymoron to begin with.  So the quality of the MySQL RNG is probably a
non issue.

>> BTW: Does the MySQL sort algorithm
>> preserve relative positions for rows with duplicate keys?

>This is an interesting question, and I'd guess that it doesn't.
>Besides, the order of rows in a table isn't all that well-defined
>anyway. Still, some tests on this would be interesting to see.

I just ran a quick test.
I created a table with 2 integer columns, the first is auto_increment.
I then dumped 100 records into it, populating the second column with random
numbers in the range 0->100.  This gives me lots of duplicate values for the
second column.

In inspecting the table after sorting by the second column, the relative
order was always preserved.  It's not conclusive, but it looks like relative
order is preserved.

You could also do ORDER BY RAND(), which I just discovered in the DuBois
book when looking for the syntax of the RAND() function (which I haven't
used before).

---------------------------------------------------------------------
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