This is probably because of a bug in MySQL versions before 3.23.56 and
4.0.10 -- RAND() didn't work right the first time it was used in a *new*
connection. After the first run, though, it was OK.
To work around the problem, I've told people to just call RAND() a few
times before doing your query. Just like this in PHP:
mysql_query('SELECT RAND(), RAND(), RAND()');
Then the ORDER BY RAND() query should be random. Now that I think about
it, putting RAND() twice in the ORDER BY would probably have the same
effect. So you could try
$result = mysql_query('... ORDER BY RAND(), RAND() LIMIT 1');
Hope that helps.
----- Original Message -----
Sent: Tuesday, November 04, 2003 10:33 AM
Subject: RAND ()
> I have been playing around with RAND(). It works very well if I do a
> statement with mysql, but I having problem using with mysql statement
> with php. When a person calls on the page, the same output is always
> view. How can I get RAND() work with php.
> sorry for the php, stuff. Thanks for any help you can give.
|• RAND ()||Payne||4 Nov|
| • Re: RAND ()||Matt W||5 Nov|