Exclude an exact match
Find records whose scalar field differs from a specified value.
Prisma · Const
Prisma's not filter excludes records whose scalar field matches a specified value or condition. On nullable fields, it does not include NULL rows unless an OR branch explicitly includes them.
Use not inside a scalar field filter to exclude records whose field matches a value or another supported condition. For nullable columns, the filter excludes NULL rows too; combine it with OR when NULL values must also be included.
{ not: n }| Name | Type | Description |
|---|---|---|
n | field value or filter condition | The value or supported field-filter condition that the field must not match. |
A Prisma Client query result containing records whose field does not match the supplied value or condition.
not filter selects records whose field value differs from the supplied value.not inside the where object of a Prisma Client query.isNot, not the scalar not filter.not does not include rows whose value is NULL.const users = await prisma.user.findMany({
where: {
name: { not: "Eleanor" },
},
});This returns users whose name differs from the specified value.
Find records whose scalar field differs from a specified value.
Filter out records matching a supported string or scalar condition.
Combine exclusion with a null branch when nullable data must remain in the result.
not filter do?not is a field-level filter that selects records whose value does not equal the supplied value. For example, name: { not: "Eleanor" } excludes users named Eleanor.
Follow-up: How would you include NULL names too? Add an OR condition containing name: null alongside the not condition.
not is used on a nullable field?A nullable column's NULL values are not returned by a not filter. This follows SQL null semantics: NULL is not treated as an ordinary value that differs from the comparison value.
Follow-up: How can you test for records where the field is specifically NULL? Use a field filter with null, such as name: null.
not exclude conditions other than equality?not can be used with a field filter to exclude an exact value, while Prisma's broader filter operators can express negated conditions such as a value not containing a string. The exact syntax depends on the field's supported filter type.
Follow-up: How can multiple negated conditions be combined? Use the logical NOT operator for compound conditions.
ORNOTisNotequalscontains