The condition expression in a WHERE clause of a SOQL query includes one or more field expressions. You can specify multiple field expressions in a condition expression by using logical operators.
Syntax
1WHERE conditionExpression
conditionExpression
The conditionExpression uses the following syntax:
The field expression syntax of the WHERE clause in a SOQL query consists of a field name, a comparison operator, and a value. The query uses these components to compare the field name value to records being searched.
1fieldName comparisonOperator value
Syntax
Description
fieldName
The name of a field for the specified object. Use of single or double quotes around the name result in an error. You must have at least read-level permissions to the field. It can be any field except a long text area field, encrypted data field, or base64-encoded field. The name doesn’t need to be a field in the fieldList.
comparisonOperator
Operators that compare values, such as =,<=, IN, and LIKE. String comparison behavior depends on the field and the locale of the user who executes the query. See Comparison Operators.
value
A value used to compare with the value in the fieldName. Supply a value whose data type matches the field type of the specified field. The value must be a valid value, not other field names or calculations. If quotes are required, use single quotes. Double quotes result in an error. Quotes are unnecessary for dates and numbers.
You can use parentheses to define the order in which fieldExpressions are evaluated. You must specify parentheses when nesting operators. However, multiple operators of the same type don’t need to be nested. In the following example, the expression is true if fieldExpression1 is true and either fieldExpression2 or fieldExpression3 are true.
1fieldExpression1 AND (fieldExpression2 OR fieldExpression3)
However, the following expression is true if either fieldExpression3 is true or both fieldExpression1 and fieldExpression2 are true.
1(fieldExpression1 AND fieldExpression2) OR fieldExpression3