SELECT t.* FROM table t WHERE t.Id > 'a' ORDER BY t.Id LIMIT 2;
There is no implied order in rows in a table; so absent an ORDER BY clause, the database is free to return rows in an arbitrary order. And absent an ORDER BY, it's not possible to guarantee that a subsequent query will not return a previously returned rows.
So, for you to know that the "second row" has an Id value of 'a'
, that implies that some ordering has been applied. My example query assumes that the rows are ordered by the Id column.
With a specified ordering, it's possible for a query to return the "next N" rows, using a predicate (condition in the WHERE clause) that specifies that only rows "following" the last retrieved value are to be returned. The LIMIT clause is applied after the rows are ordered, so that we are guaranteed to get the "next N rows" (in ordered sequence.)
The more general form, if the rows are being ordered on something other than a unique key, requires a slightly more complicated predicate, to handle the equality condition, where the next row to be retrieved has a value that matches the last retrieved...
SELECT t.*
FROM table t
WHERE ( t.col = last_col_value_retrieved AND t.id > last_id_value_retrieved )
OR ( t.col > last_col_value_retrieved )
ORDER BY t.col, t.id
LIMIT 50