note 29692 added to ref.mysql
| From: | past at sbox dot tugraz dot at | Date: | Fri, 21 Feb 2003 20:17:02 +0000 |
| Subject: | note 29692 added to ref.mysql | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44325@lists.php.net to get a copy of this message | ||
As MySQL docs say, RAND() is not very usefull for generation of randomized result orders.
But this worked for me on Linux, however:
Somewhere before:
mt_srand((double)microtime()*1000000);
"SELECT *, " RAND(".mt_rand(0,86622340).")*10000%100 AS randomvalue ORDER BY
randomvalue"
The upper value for mt_rand() has to be Quite Big to see any effect on MySQL's RAND(). The
exact number shouldn't be significant. Note the multiplication and modulo; MySQL seems to count
steadily upwards when generating random numbers, so we take some numbers from between.
--
http://www.php.net/manual/en/ref.mysql.php
http://master.php.net/manage/user-notes.php?action=edit+29692
http://master.php.net/manage/user-notes.php?action=delete+29692
http://master.php.net/manage/user-notes.php?action=reject+29692