BETWEEN

fun <T : Any> KQLiteColumn<in T>.BETWEEN(start: T, end: T): Clause.Expression

Creates a BETWEEN expression to check if the column's value is within a specified range (inclusive).

This function generates a SQL BETWEEN ? AND ? clause. It is a concise way to check if a value falls within a lower and upper bound, including the bounds themselves.

Example

// Find employees with an age between 25 and 35 (inclusive)
// Generates: "age" BETWEEN 25 AND 35
Employees.age.BETWEEN(25, 35)

// Find orders placed in the first quarter of the year
// Generates: "order_date" BETWEEN '2023-01-01' AND '2023-03-31'
Orders.orderDate.BETWEEN("2023-01-01", "2023-03-31")

Return

An Expression representing the BETWEEN condition.

Author

MOHAMMAD AZIM ANSARI

Parameters

start

The lower bound of the range (inclusive).

end

The upper bound of the range (inclusive).

See also


Creates a BETWEEN expression to check if a column's value is within the range defined by two other columns.

This function generates a SQL BETWEEN "column_start" AND "column_end" clause, which is useful for dynamic range comparisons where the bounds are stored in other columns of the same or a related table. The comparison is inclusive.

Example

// Find products where the current price is between the minimum and maximum allowed price
// Generates: "current_price" BETWEEN "min_price" AND "max_price"
Products.currentPrice.BETWEEN(Products.minPrice, Products.maxPrice)

Return

An Expression representing the BETWEEN condition.

Author

MOHAMMAD AZIM ANSARI

Parameters

start

A KQLiteColumn representing the lower bound of the range (inclusive).

end

A KQLiteColumn representing the upper bound of the range (inclusive).

See also


Creates a BETWEEN expression using a Kotlin ClosedRange (e.g., 1..10).

This infix function provides a more idiomatic Kotlin way to check if a column's value falls within an inclusive range. It generates a standard SQL BETWEEN ? AND ? clause. This is particularly useful for numeric, date, or string ranges.

Example

// Find employees with an age from 25 to 35 (inclusive)
// Generates: "age" BETWEEN 25 AND 35
Employees.age BETWEEN 25..35

// Find tracks with a length between 3 and 5 minutes (stored as seconds)
// Generates: "duration_seconds" BETWEEN 180 AND 300
Tracks.durationSeconds BETWEEN 180..300

Return

An Expression representing the BETWEEN condition.

Author

MOHAMMAD AZIM ANSARI

Parameters

range

The ClosedRange to check against. The start and endInclusive values of the range are used as the lower and upper bounds.

See also

(start, end)