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

Drizzle ORM · Function

isNotNull

isNotNull creates a Drizzle filter that keeps rows whose value is not SQL NULL. Use it in where() to generate an IS NOT NULL predicate.

How it works

isNotNull builds a SQL predicate that tests whether a column or SQL expression is not NULL. Pass it to where() to retain only rows satisfying the IS NOT NULL condition.

Syntax

isNotNull(column)

Returns

A SQL filter expression representing an IS NOT NULL condition.

Key points

  • isNotNull represents the condition that a value is not null.
  • Import isNotNull directly from the drizzle-orm package.
  • Use the predicate as the argument to a select query's where() method.
  • The generated SQL applies IS NOT NULL to the referenced column.

Example: Filter out NULL values

import { isNotNull } from "drizzle-orm";
import { users } from "./schema";

const rows = await db
  .select()
  .from(users)
  .where(isNotNull(users.email));

Selects users whose email column is not SQL NULL.

When to use it

Keep rows with a populated nullable column

Nullable database fields

Express an IS NOT NULL condition without raw SQL

Query filtering

Interview questions

QWhat does isNotNull do?

isNotNull creates a filter for values that are not SQL NULL. Used in where(), it generates an IS NOT NULL predicate for the selected column.

Follow-up: What SQL does it represent? It represents a condition such as "column" IS NOT NULL, as shown by the operator documentation.

QHow is isNotNull used in a Drizzle query?

Import isNotNull from drizzle-orm, then pass the target table column to it inside a query's where() clause. The result is a type-safe Drizzle filter expression.

Follow-up: How would you combine it with another condition? Use Drizzle's documented filter-composition operators, such as and(), around the individual predicates.

QWhat result does an isNotNull filter produce?

The predicate excludes rows where the tested value is NULL and keeps rows where it is not NULL. Drizzle translates that predicate into SQL rather than requiring a handwritten SQL fragment.

Follow-up: How does the generated SQL express the test? It uses the SQL IS NOT NULL operator on the referenced column.

  • isNull
  • and
  • or

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