MySQL RAND() function is broken!
Posted: Sat 29 Nov 2014 4:34 pm
A little warning...
I was using the MySQL RAND() function to pull a random 'fact of the day' from a database table. Because I wanted the fact to remain the same for the duration of the day, and new 'random' fact to be chosen the next day, I seeded RAND() with an integer based on the year and day of the year - YYYYDDD. I noticed that the same 'facts' kept reappearing, some investigation showed that the seeding of the RAND() function is seriously broken/flawed in MySQL 5.6 - See http://stackoverflow.com/questions/2718 ... ost-repeat.
I was using the MySQL RAND() function to pull a random 'fact of the day' from a database table. Because I wanted the fact to remain the same for the duration of the day, and new 'random' fact to be chosen the next day, I seeded RAND() with an integer based on the year and day of the year - YYYYDDD. I noticed that the same 'facts' kept reappearing, some investigation showed that the seeding of the RAND() function is seriously broken/flawed in MySQL 5.6 - See http://stackoverflow.com/questions/2718 ... ost-repeat.