Randomize Result Set Order
Is there an easy way to randomize the order that records get returned in?
Don't imagine there is - but thought I'd ask ;)
Thanks
Ryan Mahoney
"Ryan" == Ryan Mahoney <ryan@paymentalliance.net> writes:
Ryan> Is there an easy way to randomize the order that records get returned in?
Ryan> Don't imagine there is - but thought I'd ask ;)
order by random()
I even threw it into my latest Linux Magazine column, expounding the
virtues of the official Database of RedHat.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
"Ryan" == Ryan Mahoney <ryan@paymentalliance.net> writes:
Ryan> Is there an easy way to randomize the order that records get returned in?
Ryan> Don't imagine there is - but thought I'd ask ;)order by random()
I even threw it into my latest Linux Magazine column, expounding the
virtues of the official Database of RedHat.
I still haven't figured out how that function call does this trick.
My guess is that because we can order by a function, it is calling
random() for every row and just sorting on that. In normal usage, the
functionm would reference database columns.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026