Select values inside numeric bounds
Range filtering
Drizzle ORM · Function
between is a built-in Drizzle filter operator for selecting rows whose column value lies within a supplied range. Import it from drizzle-orm and pass the resulting condition to .where().
between creates a SQL range predicate for a column or expression. Pass the value to test and the lower and upper bounds, then use the result in a query condition such as .where().
between(column, lower, upper)| Name | Type | Description |
|---|---|---|
column | column or SQL expression | The column or expression whose value is tested. |
lower | value | The lower endpoint of the range. |
upper | value | The upper endpoint of the range. |
A SQL filter condition representing a BETWEEN predicate.
between as part of its built-in filter and conditional operator support.between from the main drizzle-orm package..where() to restrict selected rows to a specified range.import { between } from "drizzle-orm";
const rows = await db
.select()
.from(table)
.where(between(table.column, 2, 7));Filters rows whose column value falls between the two supplied bounds.
Range filtering
Query composition
Dialect-aware filtering
between in a Drizzle query?between is a Drizzle filter operator imported from drizzle-orm. It is used inside a query condition, for example .where(between(table.column, 2, 7)).
Follow-up: How would you combine it with another condition? Use Drizzle's conditional operators, such as and() or or(), around the between expression.
between receive?The first argument identifies the column being tested, while the second and third arguments provide the range endpoints. The resulting predicate can be passed to .where().
Follow-up: What should you verify when bounds are dynamic? Ensure the bound values have types compatible with the selected column.
between imported from and where is it placed?Import it directly from drizzle-orm, then place the expression in the query builder's filtering clause. The official example uses between(table.column, 2, 7).
Follow-up: Can it be used without a query builder? The documented usage demonstrates it as a filter expression supplied to a query's .where() clause.
andornoteqgtgteltlte