1

How can I implement the pagination in GridDB api like fetching a smaller chunk of data from the database at a time and allow us to fetch the next chunk by defining the page size (number of records per query) and the page number.

I have the following Pet table.

id petname category age
1 AMOR Dog Young
2 Belle Dog Adult

Now I need a query that may fetch a few records at a time and the rest of it next time. I used the following query, but this returns the first few records only.

Select * from pets limit 3;

How can I fetch 3 records first time, then 3 records second time and so on. Using "limit" only allows me to get the first x number of records.

asked Jun 9, 2022 at 6:23
0

1 Answer 1

1

The GridDB documentation shows that LIMIT value_1 [OFFSET value_2 ] is valid syntax.

In light of that revelation, it's probably something like this:

SELECT *
FROM pets
ORDER BY pets.pet_key
LIMIT 3 OFFSET 0;

Which would get the first three rows ordered by the pet_key column. To get the next three rows, you'd use:

SELECT *
FROM pets
ORDER BY pets.pet_key
LIMIT 3 OFFSET 3;
answered Jul 22, 2022 at 15:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.