WHERE Clause

By default, a SQL query retrieves every row in your dataset. Use the optional WHERE clause to restrict your query results to a conditional expression.

The conditional expression in the WHERE clause takes the following syntax.

Count
510

You can add multiple field expressions to conditional expressions with logical operators.

Count
1,257

The WHERE clause supports these operators.

TypeOperator NameSupported Types
Comparison Operators!=, =Numeric, String, Boolean
 <, <=, >, >=Numeric, String
 IN, NOT INNumeric, String
Null OperatorsIS NULL, IS NOT NULLNumeric
Logical OperatorsAND, OR, NOTBoolean

The left operand of a comparison operator must be a valid field. The right operand cannot be a field. Arithmetic operators (e.g. +, -, /, *, %) between supported types can be used on the right hand side.

WHERE is limited to comparisons within a single column.

In a non-nested query (a non-subquery), you can’t pass fields to a math or string function in a WHERE clause. You can pass a constant. To pass fields to a math or string function in a subquery, include it in the outer query’s WHERE clause. If you use it in the innermost query, SQL throws an error.