Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Drizzle ORM · Function

between

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().

How it works

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().

Syntax

between(column, lower, upper)

Parameters

NameTypeDescription
columncolumn or SQL expressionThe column or expression whose value is tested.
lowervalueThe lower endpoint of the range.
uppervalueThe upper endpoint of the range.

Returns

A SQL filter condition representing a BETWEEN predicate.

Key points

  • Drizzle provides between as part of its built-in filter and conditional operator support.
  • Import between from the main drizzle-orm package.
  • Use the operator directly inside .where() to restrict selected rows to a specified range.

Example: Filter with between

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.

When to use it

Select values inside numeric bounds

Range filtering

Use a range predicate in a select query

Query composition

Apply a built-in conditional operator across supported SQL dialects

Dialect-aware filtering

Interview questions

QHow do you use 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.

QWhat arguments does 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.

QWhere is 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.

  • and
  • or
  • not
  • eq
  • gt
  • gte
  • lt
  • lte

Source: Filters - Drizzle ORM. Checked 2026-10-16.