Answer the question
In order to leave comments, you need to log in
How to select records from the database cyclically?
Help me figure it out.
Given
a database with entries being added and removed.
The entries are grouped into categories.
Roughly speaking, one category of records is a stack of paper sheets.
There are tens of thousands of entries in each category.
Required: take the topmost sheet from the stack, return it to the calling script, and put the sheet itself at the very bottom of the stack. and so on in a circle.
I can not figure out how to do it logically, and as a result, technically.
There was an idea to prescribe serial numbers for each position, and after selecting an element, update all numbers in the database. But it's kind of hard.
There was an idea to mark the last selected element with a flag (similar to the cursor). But it is not clear what to do if the marked element is removed from the database.
I feel that there is a simple solution, but I can not figure it out.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question