limit

abstract fun limit(limit: Int): SelectStatement<T>

Same as calling limit(limit, -1)


abstract fun limit(limit: Int, offset: Int): SelectStatement<T>

Adds a LIMIT clause to the SELECT statement, constraining the number of rows returned.

The LIMIT clause is used to specify the maximum number of rows the result set can have. An optional OFFSET can be provided to skip a certain number of rows before starting to return them. This is commonly used for implementing pagination.

If offset is not specified or is negative, no rows are skipped.

Example

// Selects the first 10 employees
val firstTen = Employees.select().limit(10).execute()

// Selects 10 employees starting from the 21st row (skipping the first 20)
// This is useful for fetching the third page of results if the page size is 10.
val pageThree = Employees.select().limit(10, 20).execute()

Return

The SelectStatement instance, allowing for further chaining of query-building methods.

Author

MOHAMMAD AZIM ANSARI

Parameters

limit

The maximum number of rows to return.

offset

The number of rows to skip before starting to return rows. Defaults to -1 (no offset).