Good day.
It is necessary to make pagination with a random value of people.
Just in the sql rand I can not specify, because one person can get on several pages.
Is it possible, somehow by date / time, to output a random list of people on a page or something else?
thank

  • [] () RAND (100500) However, there is a suspicion that the pages will be the same as long as the number of records in the table is constant. - ReinRaus
  • the joke is that, let's say, I first select page 1 - 10 people were brought out. Then page 2 - another 10 was published ... but they should not happen again, and this is possible - Rakzin Roman
  • It seems to me that the problem can be solved only if the number of rows in the table is fixed. Initially, "initialize" the paginator: you define two numbers for it - the number of records in the table and the "randomizer initializer". Next, from page to page, you transmit these two numbers and use them to determine on which page which records to show by randomly mixing a range of numbers based on the "randomizer initializer". It is also desirable to have this same array as a cache on the client. - ReinRaus

1 answer 1

It’s not entirely clear to all users whether the same (random) order should be, whether the order should change according to F5, it’s not completely clear whether the order should change tomorrow or the first page for the same user should be fixed .. .

In any case, as an initial decision you can do:

order by md5(id+$seed) 

where $ seed can be substituted so that it is implemented immediately for several options.

The speed of calculating md5, of course, will slow down the selection, and most likely significantly, so you should think about alternatives.

  • good decision :) - Barmaley