"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
--- Martin Fowler
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).
With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15
To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:
SELECT * FROM tbl LIMIT 95,18446744073709551615;
With one argument, the value specifies the number of rows to return from the beginning of the result set:
SELECT * FROM tbl LIMIT 5; # Retrieve first 5 rows
In other words, LIMIT row_count is equivalent to LIMIT 0, row_count.
I hadn't been here for fifteen years
A.J. Côté wrote:
an additional:
select count(*) from tbl;
is usually also used to get the total number of result available.
Martin Bechtle wrote:
Basically it's telling you how to do pagination on the client side.
Martin Bechtle wrote:
If I were you I would...
1- use Spring Boot instead of Spring
2- use thymeleaf rather than jsp
3- use Spring Data
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
--- Martin Fowler
Partheban Udayakumar wrote:
That is what I don't understand in it. He just loops 5 data once and then at last he again loops data pageDisplayLength-5 times. How does it get paginated?
Partheban Udayakumar wrote:
I am working on getting to know about Spring Boot and thymeleaf and in my actual project I am using Spring Data and I know about Page classes there. I am just wondering if its simple as looping will paginate your data, why should we use Spring Data and Page classes.
Martin Bechtle wrote:It is really paginated by jQuery on the client side, once the data is fetched from the server
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
--- Martin Fowler