---
schema_version: "1"
id: bc647973940dc44ff057a71a31d4fd031762b125f811a19dce8749952b68f4ed
title: Use null in WHERE
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-soql-sosl/guides/soql-sosl/sforce-api-calls-soql-null.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-null.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7217b8e37bd59bd9ef091334efee6e4408783293cf4bacf375077b7ab7e49673
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# Use null in WHERE

You can search for null values by using the `null` keyword in SOQL queries.

This example query returns the account IDs of all events with a non-null activity date.

<!-- otherprops: soql -->

```codesegment
SELECT AccountId
FROM Event
WHERE ActivityDate != null
```

If you run a query on a boolean field, null matches FALSE values. For example, if `Test_c` is a boolean field, then the following query returns all the account records where `Test_c` is false:

<!-- otherprops: soql -->

```codesegment
SELECT Id, Name Test_c
FROM Account
WHERE Test_c = null
```

The clause `WHERE Test_c = null` is equivalent to `WHERE Test_c = false`. The clause `WHERE Test_c != null` is equivalent to `WHERE Test_c = true`.

The `WHERE` clause behaves in two different ways, depending on the version, when handling null values in a parent field for a relationship query. In a `WHERE` clause that checks for a value in a parent field, the record is returned even if the parent does not exist.

```soql
SELECT Id
FROM Case
WHERE Contact.LastName = null
```

Case record `Id` values are returned.

**See Also**

- [null Values in Lookup Relationships and Outer Joins](https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-relationships-lookup.md)
