---
schema_version: "1"
id: 0e4cdea3c4463402a2a355b26a4dd64a9f91c176db7bf4b5ea798146f109f4f9
title: 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-select-conditionexpression.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-select-conditionexpression.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f6c1b7e432b1fe96849b6755b50debb76240cbc46e4181bd12cd6757eda838dd
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# WHERE

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

```soql
WHERE conditionExpression
```

## `conditionExpression`

The conditionExpression uses the following syntax:

```soql
fieldExpression [logicalOperator fieldExpression2][...]

```

**note:** Strings in `WHERE` clauses can’t exceed 4,000 characters. This limit doesn’t apply to SOQL queries in Apex if the `WHERE` clause includes the `IN` operator.

The condition expressions in SOQL `SELECT` statements appear in bold in these examples:

- `SELECT Name FROM Account WHERE Name LIKE 'A%'`
- `SELECT Id FROM Contact WHERE Name LIKE 'A%' AND MailingState='California'`

You can use date or dateTime values, or date literals. The format for date and dateTime fields are different.

- `SELECT Name FROM Account WHERE CreatedDate > 2011-04-26T10:00:00-08:00`
- `SELECT Amount FROM Opportunity WHERE CALENDAR_YEAR(CreatedDate) = 2011`

For information on date functions, such as `CALENDAR_YEAR()`, see [Date Functions](https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-select-date-functions.md).

You can use the boolean values `TRUE` and `FALSE` in SOQL queries. To filter on a boolean field, use the following syntax:

```soql
WHERE BooleanField = TRUE

WHERE BooleanField = FALSE

```

## fieldExpression

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.

```soql
fieldName 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](https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-select-comparisonoperators.md).                                                                                    |
| 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`.

```soql
fieldExpression1 AND (fieldExpression2 OR fieldExpression3)
```

However, the following expression is `true` if either `fieldExpression3` is `true` or both `fieldExpression1` and `fieldExpression2` are `true`.

```soql
(fieldExpression1 AND fieldExpression2) OR fieldExpression3
```
