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

Drizzle ORM · Function

lte

lte creates a less-than-or-equal filter condition in Drizzle ORM. It supports comparing a column with a value or comparing two columns.

How it works

Use lte in a query condition to keep rows whose first operand is less than or equal to the second operand. The operands can be a table column and a value, or two columns, and Drizzle emits the corresponding SQL <= comparison.

Syntax

lte(left, right)

Parameters

NameTypeDescription
leftSQL expressionThe first value or table column to compare.
rightSQL expressionThe value or table column that the left operand must be less than or equal to.

Returns

A SQL predicate representing a less-than-or-equal comparison.

Key points

  • lte keeps values that are at most the supplied comparison operand.
  • Import the operator from the main drizzle-orm package.
  • Use lte as the predicate passed to a query builder’s where clause.
  • A literal comparison is translated to SQL using the <= operator.
  • The operator also accepts two columns for column-to-column comparison.

Example: Filter with lte

import { lte } from "drizzle-orm";

const query = db
  .select()
  .from(table)
  .where(lte(table.column, 5));

Selects rows where the column value is less than or equal to 5.

When to use it

Maximum-value filtering

Restrict numeric results to a maximum threshold.

Column-to-column comparison

Keep records whose one column does not exceed another.

Range and compound filters

Use a boundary condition as part of a composed query predicate.

Interview questions

QWhat does Drizzle ORM’s lte operator do?

lte represents a less-than-or-equal comparison. For example, lte(table.column, 5) produces a condition equivalent to table.column <= 5.

Follow-up: Can the right-hand operand be another column? Yes. Passing two columns compares their values, such as lte(table.column1, table.column2).

QHow do you use lte in a query?

Import lte from drizzle-orm, then pass the column and comparison value to it inside .where(). The resulting predicate is used to filter selected rows.

Follow-up: How would you combine this condition with a range? Compose it with other predicates, such as a greater-than condition, using Drizzle’s logical operators.

QWhat SQL comparison does lte generate?

When given a column and a literal, lte generates a SQL less-than-or-equal predicate, for example WHERE "table"."column" <= 5. It can also compare one column directly with another.

Follow-up: What SQL does a column-to-column comparison represent? It generates a predicate such as WHERE "table"."column1" <= "table"."column2".

  • lt
  • gt
  • gte
  • and
  • eq
  • ne

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