InfluxDB Clustered is currently only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.
- Time ranges
- Regular expressions
- WHERE clause examples
- Notable behaviors
SELECT_clause FROM_clause WHERE <conditional_expression> [(AND|OR) <conditional_expression> [...]]
- conditional_expression: Comparison between two operands that evaluates to
false. Comparison logic is determined by operators used in the expression. These expressions can operate on InfluxDB fields, tags, and timestamps. Use logical operators (
OR) to chain multiple conditional expressions together.
Operators evaluate the relationship between two operands and return
|Operator||Meaning||Supported data types|
|Not equal to||all|
|Not equal to||all|
|Greater than||numeric, timestamp|
|Greater than or equal to||numeric, timestamp|
|Less than||numeric, timestamp|
|Less than or equal to||numeric, timestamp|
|Matches a regular expression||strings|
|Doesn’t match a regular expression||strings|
WHERE clause to specify a time range to query.
If a time range isn’t specified in the
WHERE clause, the default time range is used.
Timestamps are stored in the
Use comparison operators to compare the value of the
time column to a
timestamp literal, integer (Unix nanosecond timestamp), or expression.
WHERE time >= '2023-01-01T00:00:00Z' AND time < '2023-07-01T00:00:00Z'
WHERE time >= 1672531200000000000 AND time < 1688169600000000000
WHERE time >= now() - 1d AND time < now()
See Time syntax
for information on how to specify alternative time ranges in the
Regular expressions can be used to evaluate string values in the
using regular expression comparison operators:
=~: Matches a regular expression
!~: Doesn’t match a regular expression
SELECT * FROM home WHERE room =~ /^K/
For more information about InfluxQL regular expression syntax, see InfluxQL regular expressions.
WHERE clause examples
The following examples use the Get started home sensor sample dataset.
Single and double quotes
In InfluxQL, single quotation marks (
') and double quotation marks (
differently and can alter the way a
WHERE clause functions.
Single quotes are used in string
and timestamp literals.
Double quotes are used to quote identifiers,
(time, field, and tag column names).
For example, the following conditional expression compares the value of the
location column to the literal string,
"location" = 'London'
The following conditional expression compares the value of the
to the value of the
"location" = "London"
Misused double and single quotes in the
WHERE clause often results in unexpected
empty query results.
For more information about quotation marks, see
Cannot query multiple time ranges
InfluxDB does not support using
OR in the
WHERE clause to query multiple time ranges.
For example, the following query returns no results:
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.