Inclusive lower-bound filtering
Retrieve records meeting a minimum numeric, date, or ordered-value threshold.
Drizzle ORM · Function
gte builds a Drizzle filter for values greater than or equal to a threshold. Use it in where clauses with a literal or another column.
The gte operator creates a comparison condition where the first operand is greater than or equal to the second. Use it in a query's where clause with a column and a literal value, or compare two columns directly.
gte(column, valueOrColumn)| Name | Type | Description |
|---|---|---|
left | SQL expression | Column or SQL expression whose value is tested. |
right | value or SQL expression | Literal value or column/SQL expression compared with the first operand. |
A SQL condition representing a greater-than-or-equal comparison.
gte keeps rows whose left-hand value is at least the right-hand value, including equality.gte from the main drizzle-orm package alongside other filter and conditional operators.where clause to filter selected rows.>=.import { gte } from "drizzle-orm";
const result = await db
.select()
.from(users)
.where(gte(users.age, 18));Selects users whose age is at least 18.
Retrieve records meeting a minimum numeric, date, or ordered-value threshold.
Select rows where one field is at least as large as another field in the same row.
Compose a minimum-value predicate with other Drizzle conditions in a larger query.
gte operator do?gte means “greater than or equal to” and is imported from drizzle-orm. In a where clause, gte(table.column, 5) produces a comparison equivalent to column >= 5.
Follow-up: Can the right-hand operand be another column? Yes: pass the second column expression, such as gte(table.column1, table.column2), to compare columns directly.
The first argument is the column or expression being tested, and the second is the threshold or comparison expression. For example, gte(users.age, 18) retains rows where users.age is at least 18.
Follow-up: What SQL comparison does it represent? It represents >=, so equality is included along with larger values.
gte compare two columns?Use gte in the query builder's where method after selecting from a table. The resulting condition can compare a column against either a value or another column.
Follow-up: How should dynamic values be supplied? Pass them as the second argument; Drizzle parameterizes filter-operator values automatically.
gteqneandorsql