Newer Version Available

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

Logical Operators

The following table lists the logical operator values that are used in fieldExpression syntax:

Operator Syntax Description
AND fieldExpressionX AND fieldExpressionY true if both fieldExpressionX and fieldExpressionY are true.
OR fieldExpressionX OR fieldExpressionY true if either fieldExpressionX or fieldExpressionY is true.

Relationship queries with foreign key values in an OR clause behave differently depending on the version of the API. In a WHERE clause using OR, if the foreign key value in a record is null, the record is returned in version 13.0 and later, but not returned in versions before 13.0.

1SELECT Id FROM Contact WHERE LastName = 'foo' or Account.Name = 'bar'
The contact with no parent account has a last name that meets the criteria, so it is returned in version 13.0 and later.
NOT not fieldExpressionX true if fieldExpressionX is false.

There is also a comparison operator NOT IN, which is different from this logical operator.