order By
Adds an ORDER BY clause to the UPDATE statement for single column and default sorting.
Adds an ORDER BY clause to the UPDATE statement.
This is typically used in conjunction with a LIMIT clause to control which rows are updated when the set of rows matching the WHERE clause is larger than the limit. The ORDER BY clause determines the order in which rows are considered for the update.
Note: The ORDER BY clause in an UPDATE statement is a non-standard SQLite extension.
Example
// Update the oldest 5 pending orders to 'processing'.
Orders
.update {
it.status.bind("processing")
}.where {
it.status EQ "pending"
}.orderBy(
Orders.orderDate,
sort = Sort.ASC
).limit(5)
.execute()Return
The UpdateStatement instance for further chaining.
Author
MOHAMMAD AZIM ANSARI
Parameters
The KQLiteColumn to sort the rows by.
See also
Adds an ORDER BY clause to the UPDATE statement using OrderColumn objects. Same as calling orderBy(column, null)
Adds an ORDER BY clause to the UPDATE statement using one or more OrderColumn objects.
This overload is useful for sorting by multiple columns, each with its own sorting direction or nulls handling. It is typically used with a LIMIT clause to control which rows are updated.
Note: The ORDER BY clause in an UPDATE statement is a non-standard SQLite extension.
Example
// Update the top 10 employees, prioritizing those with a higher bonus,
// and then by their hire date in descending order.
Employees
.update {
it.reviewStatus.bind("Completed")
}.where {
it.reviewStatus EQ "Pending"
}.orderBy(
OrderColumn(Employees.bonus, null, Sort.DESC, Nulls.FIRST),
OrderColumn(Employees.hireDate, null, Sort.DESC)
).limit(10)
.execute()Return
The UpdateStatement instance for further chaining.
Author
MOHAMMAD AZIM ANSARI
Parameters
The primary OrderColumn for sorting.
An optional secondary OrderColumn for sorting. To sort by more than two columns, nest OrderColumn instances.