In my website I implement the standard data loading when scrolling down the page. To implement such a solution, it naturally comes to mind to use the normal LIMIT in database queries with an offset.
But I have a question:
How to correctly take into account the changed data in the process?
For example, we have 400 employee records in the database. Employees have an is_work field (Works). When opening, the page requests the first batch of working employees.
SELECT * FROM users WHERE is_work = TRUE LIMIT 0, 20 After we got the first page in our database, some of the strings in the is_work field could have changed. These changes could be made both by us and other users.
And it turns out that the following query using LIMIT 20, 20 will not return the data we would like to receive. (Or those depending on where the changes will be made)
Is there any standard solution to this issue?
Comment:
I can solve this problem in several not very beautiful ways, including getting the whole array, using the NOT IN construct, etc. (By ugly, I mean all the ways, the implementation of which will slow down in direct proportion to the growth of the base).