If you need a pseudo-random order, you can do something like this (PHP):
$seed = md5(mt_rand()); $prng = ('0.' . str_replace(array('0', 'a', 'b', 'c', 'd', 'e', 'f'), array('7', '3', '1', '5', '9', '8', '4'), $seed )) * 1; $query = 'SELECT id, name FROM table ORDER BY (substr(id * ' . $prng . ', length(id) + 2)';
In addition, you can set $ seed to a predefined value and always get the same results.
I learned this trick from my colleague http://steamcooker.blogspot.com/
jankkhvej Mar 18 '10 at 13:02 2010-03-18 13:02
source share