Since you can pass the seed parameter to the RAND() function, you can βbreakβ into random results by creating a seed before the first page.
Code example: For the first page (depending on the language):
int seed = Math.abs(new Random().nextInt());
SQL query:
SELECT url FROM masterurls ORDER BY RAND({seed}) LIMIT 200;
Store the seed somewhere (for web applications you can use a parameter or url session). For the following pages:
SELECT url FROM masterurls ORDER BY RAND({seed}) LIMIT 200 * {pageNumber}, 200;
Note. Sorting by RAND() is a tough operation, you might be better off storing an indexed column with a URL hash code, and then use modular or other random functions.
The scrum meister
source share