Room - Is it possible to use OFFSET and FETCH NEXT in a query? Room - Is it possible to use OFFSET and FETCH NEXT in a query? database database

Room - Is it possible to use OFFSET and FETCH NEXT in a query?


This is how I managed to achieve and it's working just fine:

(Kotlin sample)

SELECT * FROM Persons WHERE name LIKE :param LIMIT :pageSize OFFSET :pageIndex

where:

  • PARAM = search criteria,

  • PAGESIZE = number of rows to return per page,

  • PAGEINDEX = what page to return


The accepted answer is almost correct, the below works for me:

SELECT * FROM Persons WHERE name LIKE :param LIMIT :pageSize OFFSET :pageIndex * :pageSize