I create an mysql-statement that paginates the results using LIMIT x, n
(where x
is the offset and n
the returned entries).
The offset is created using GET-Vars in the form of page=x
.
Now Google has some strange entries in its index that come from old crawls, where the page-variable exceeds the actual amount of records in the result-set.
Means, the query created with the page variable results in something like LIMIT 1000, 30
- but the query will only return 900
entries (since the content of the table changed meanwhile. This returns an empty result-set, of course.
Is there a way to tell mysql, that if the offset exceeds the returned records to just show the last possible result-set? I don't want to make an extra query using COUNT()
first, since this would double the load on the mysql-server (right now I'm using SQL_CALC_FOUND_ROWS
to determine the total amount of records the query would return without the LIMIT
-Statement.