Re: order by rand() works not satisfying

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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++;
    }
?>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux