diff -Naur /home/harrypotter/views_module/views/modules/views_node.inc views/modules/views_node.inc --- /home/harrypotter/views_module/views/modules/views_node.inc 2007-07-14 12:30:51.000000000 -0700 +++ views/modules/views_node.inc 2008-10-04 11:27:10.000000000 -0700 @@ -761,15 +761,7 @@ } function views_handler_sort_random($action, &$query, $sortinfo, $sort) { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $query->add_orderby('', "rand()", "ASC", 'random_sort'); - break; - case 'pgsql': - $query->add_orderby('', "random()", "ASC", 'random_sort'); - break; - } + $query->add_orderbyrandom(); } function views_node_sort_handler_nid($action, &$query, $sortinfo, $sort) { diff -Naur /home/harrypotter/views_module/views/views_query.inc views/views_query.inc --- /home/harrypotter/views_module/views/views_query.inc 2007-04-12 08:18:59.000000000 -0700 +++ views/views_query.inc 2008-10-04 11:24:46.000000000 -0700 @@ -418,6 +418,23 @@ } } + function add_orderbyrandom() { + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $random = 'rand()'; + break; + case 'pgsql': + $random = 'random()'; + break; + } + if (in_array($random, $this->orderby)) { + return; + } else { + $this->orderby[] = $random; + } + } + /* * Add a simple GROUP BY clause to the query. The caller is responsible * for ensuring that the fields are fully qualified and the table is properly