Newer Version Available

This content describes an older version of this product. View Latest

Using null in SOQL Queries

You can search for null values by using the null keyword.

Use null to represent null values in SOQL queries.

For example, the following statement would return the account IDs of all events with a non-null activity date:
1SELECT AccountId
2FROM Event
3WHERE ActivityDate != null

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, if the parent does not exist, the record is returned in version 13.0 and later but is not returned in versions before 13.0

1SELECT Id
2FROM Case
3WHERE Contact.LastName = null

Note