Hi!

On Feb 05, Tue Tønning wrote:
> Hey,
> 
> I have discovered a strange error in the mysql versions mentioned in subj.
> 
> Example.
> A table with 10 entries ...i want to draw 3 randomly
> => "select fieldName from tableName order by RAND() limit 3"
> 
> this have worked for the last year or so.....but after upgrading our redhat
> 7.2 with mysql version 3.23.54 it stopped to work. It always chooses the
> same 3 entires.

try simply

 mysql -BNe 'select rand(), rand(), rand(), rand()'
 mysql -BNe 'select rand(), rand(), rand(), rand()'
 mysql -BNe 'select rand(), rand(), rand(), rand()'

to see the problem.
RAND() initialization for new connection isn't very random,
so first few rand() values differ only slightly.

It was fixed in 4.0. I will backport the fix to 3.23.
You can either upgrade to MySQL 4.0, or wait till next 3.23 release,
or use a simple workaround: run

  do benchmark(10,rand());

just after establishing connection - before first SELECT.
 
> Ohh, yeah - we code in PHP......and i have talked today with 3 other
> webdevelopment companies that have been struggeling with the same error
> after upgrading.

Easy - no need to struggling, just submit a bugreport - the bug will be
fixed at once :)
 
Regards,
Sergei

-- 
MySQL Development Team
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__  MySQL AB, http://www.mysql.com/
/_/  /_/\_, /___/\___\_\___/  Osnabrueck, Germany
       <___/

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