Re: consistent random order - Mailing list pgsql-sql

From Jeff Herrin
Subject Re: consistent random order
Date
Msg-id 6801364.59051164821457152.JavaMail.root@srv161.carpathiahost.net
Whole thread Raw
In response to Re: consistent random order  ("Aaron Bono" <postgresql@aranya.com>)
List pgsql-sql
I need it a little more random than that. In both these scenarios, the same items will always follow each other. <br
/><br/>Jeff<br /><br />----- Original Message -----<br />Why not create a random seed between 1 and the number of
possibilitiesin your web application when a user first hits the site, store that in the session and then increment it
by1 (do a modulus to wrap the numbers back to 1) and just select with an offset equal to this number?  That way you get
thefirst item chosen at random but the rest are sequential.  If you want this somewhat random, create a "random"
orderingfield on the table and sort by that so the pages are not sorted by name or id or whatever else it may normally
sortby. <br /><br />You could then take it further and use cookies so the next time that person comes to the site, the
"random"page picks up where it left off.<br /><br />Just an idea...<br clear="all" /><br />-- <br
/>==================================================================<br />   Aaron Bono<br />   Aranya Software
Technologies,Inc.<br />   <a href="http://www.aranya.com/" target="_blank">http://www.aranya.com</a><br />   <a
href="http://codeelixir.com/"target="_blank">http://codeelixir.com</a><br
/>================================================================== 

pgsql-sql by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: consistent random order
Next
From: Jeff Herrin
Date:
Subject: Re: consistent random order