Filter out a value
Exclude rows matching a specific identifier or other literal value.
Drizzle ORM · Function
ne creates a type-safe inequality condition for Drizzle ORM queries. It matches rows where the first operand is not equal to the second and generates SQL with <>.
The ne operator builds a type-safe inequality predicate for a query. It compares a column with a value or another column and produces SQL using the <> operator.
ne(column, value)| Name | Type | Description |
|---|---|---|
column | Column or SQL expression | Column or SQL expression whose value is tested for inequality. |
n | Value or Column | Value or column compared against the first operand. |
A SQL predicate representing inequality, suitable for use in a query's where clause.
ne when a row should match only if the compared value differs from the supplied operand.drizzle-orm package.where clause to filter selected rows.<> inequality operator.import { ne } from "drizzle-orm";
import { users } from "./schema";
const result = await db
.select()
.from(users)
.where(ne(users.id, 5));Selects users whose id is not 5.
Exclude rows matching a specific identifier or other literal value.
Find rows where two stored columns differ.
Compose an inequality predicate with Drizzle query-builder filters.
ne operator do?ne creates a predicate that matches rows where a value is not equal to the supplied value. For example, ne(table.column, 5) generates a condition equivalent to table.column <> 5.
Follow-up: How can two columns be compared? Use the second column as the right-hand operand, such as ne(table.column1, table.column2), which generates a column-to-column <> comparison.
ne in a query?Import ne from drizzle-orm, then pass the target column and comparison value to it inside where. The resulting predicate can be used with Drizzle’s select query builder.
Follow-up: What SQL does the predicate represent? It represents an inequality condition using SQL’s <> operator.
ne compare two columns?The operator supports comparing one table column with another, not only comparing a column to a literal. Passing two columns produces a condition that checks whether their values differ.
Follow-up: Why is this useful? It lets a query express row-level comparisons directly in SQL without manually writing a raw condition.
eqgtgteltlteinArraynot