Boofo
01-22-2003, 01:42 AM
I just found this message on the mysql site:
As of MySQL 3.23.52, 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. An
example to test this would be to run the follow
command multiple times in a row. mysql -u
username -p -e'select rand()' A basic way to seed
this would be to run RAND(NOW()).
If I change this:
SELECT quote,name FROM quotes ORDER BY rand() LIMIT 1
to this:
SELECT quote,name FROM quotes ORDER BY RAND(NOW()) LIMIT 1
will it give me a more random quote than it does now? It seems to diplay the same quote every 20 or so times, right now.
They are running MySQL v3.23.54 on the server, by the way.
As of MySQL 3.23.52, 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. An
example to test this would be to run the follow
command multiple times in a row. mysql -u
username -p -e'select rand()' A basic way to seed
this would be to run RAND(NOW()).
If I change this:
SELECT quote,name FROM quotes ORDER BY rand() LIMIT 1
to this:
SELECT quote,name FROM quotes ORDER BY RAND(NOW()) LIMIT 1
will it give me a more random quote than it does now? It seems to diplay the same quote every 20 or so times, right now.
They are running MySQL v3.23.54 on the server, by the way.