mcmuney Posted August 10, 2006 Share Posted August 10, 2006 I'm using ORDER BY RAND() function, which works. The problem is that when results are > 10 and pagination is used, it randomizes the results on every page. I would like it to randomize once and when viewer goes to page 2, it should not randomize again. How can I achieve this? Thanks. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 10, 2006 Share Posted August 10, 2006 There is no good way of doing that. The purpose of using RAND() is to get a different sort order each time.The only thing I can think of off hand would be to do your query, then store the result somewhere...in a session, or in a file, so that when the user goes to the next page you are able to retrieve the same result set and get the next 10 records for them to view. Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 10, 2006 Share Posted August 10, 2006 Can you seed the random number that MySQL uses from some known point? If so you could just seed it from the same point twice, but I don't know enough about MySQL to know if you can. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 10, 2006 Share Posted August 10, 2006 According to the manual, you can:http://mysql.com/doc/refman/5.0/en/mathematical-functions.html#id3220613Which means that all he would have to do is get a random number, use it so seed mysql's RAND function, then store that number in a session to be used in all subsequent queries.Good suggestion. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.