Re: order by rand() works not satisfying
| From: | Paul Burney | Date: | Sun, 25 May 2003 17:06:22 +0000 |
| Subject: | Re: order by rand() works not satisfying | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28020@lists.php.net to get a copy of this message | ||
on 05/25/2003 12:35 PM, Merlin at news.groups@web.de appended the following
bits to my mbox:
> I am running mysql 3.23.49 on my server. There are some troubles with order
> by rand() function. It workes, but it seems, that only the first few rows
> are concidered. PHP pulls out 3 pics by random out of the table. I have
> found that this are more or less the first 50 rows. All other rows apear
> only verry rar.
>
> Is this a bug in mysql?
Just looking at the MySQL Documentation page, I see this note:
"MySQL changed the way RAND() functions, such that you MUST supply a SEED to
get an actual random number. If you do not, each new connection will return
close to the same number as the previous new connection.... A basic way to
seed this would be to run RAND(NOW())"
A couple other comments suggest other options.
<http://www.mysql.com/doc/en/Mathematical_functions.html>
Hope that helps.
Sincerely,
Paul Burney
<http://paulburney.com/>
<?php
while ($self != "asleep") {
$sheep_count++;
}
?>