Gossamer Forum
Quote Reply
mysql rand seed
Is the seed built in?

Would this work better than RAND for randomizing (saw this on a board):

$seed= rand();
$result = mysql_query("SELECT banner_pic,site_addr FROM banner_rotation WHERE width='468' AND height='60' ORDER BY RAND($seed) LIMIT 1");

But I guess the function rand() would have to be in the PERL library. Not sure if this makes a difference.
Quote Reply
Re: [scorpioncapital] mysql rand seed In reply to
Wow, this is very SCARY. I read this on a board:

"“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()).”

So the dilemma is how to properly seed this function for a LSQL select....
Quote Reply
Re: [scorpioncapital] mysql rand seed In reply to
Actually does anybody know how to use the rand() function in a Links SQL perl script? Do you have to go 'use <LIBRARY>' and include some library or its available?