Maximum-value filtering
Restrict numeric results to a maximum threshold.
Drizzle ORM · Function
lte creates a less-than-or-equal filter condition in Drizzle ORM. It supports comparing a column with a value or comparing two columns.
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.
lte(left, right)| Name | Type | Description |
|---|---|---|
left | SQL expression | The first value or table column to compare. |
right | SQL expression | The value or table column that the left operand must be less than or equal to. |
A SQL predicate representing a less-than-or-equal comparison.
lte keeps values that are at most the supplied comparison operand.drizzle-orm package.lte as the predicate passed to a query builder’s where clause.<= operator.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.
Restrict numeric results to a maximum threshold.
Keep records whose one column does not exceed another.
Use a boundary condition as part of a composed query predicate.
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).
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.
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".
ltgtgteandeqne