SQL operators
SQL operators are reserved words or characters which perform certain operations, including comparisons and arithmetic.
Arithmetic operators
Arithmetic operators take two numeric values (either literals or variables) and perform a calculation that returns a single numeric value.
Operator | Description | Example | Result |
---|---|---|---|
+ |
Addition | 2 + 2 |
4 |
- |
Subtraction | 4 - 2 |
2 |
* |
Multiplication | 2 * 3 |
6 |
/ |
Division | 6 / 3 |
2 |
% |
Modulo | 7 % 2 |
1 |
Comparison operators
Comparison operators evaluate the relationship between the left and right operands and returns true
or false
.
Operator | Meaning | Example |
---|---|---|
= |
Equal to | 123 = 123 |
<> |
Not equal to | 123 <> 456 |
!= |
Not equal to | 123 != 456 |
> |
Greater than | 3 > 2 |
>= |
Greater than or equal to | 3 >= 2 |
< |
Less than | 1 < 2 |
<= |
Less than or equal to | 1 <= 2 |
~ |
Matches a regular expression | 'abc' ~ 'a.*' |
~* |
Matches a regular expression (case-insensitive) | 'Abc' ~* 'A.*' |
!~ |
Does not match a regular expression | 'abc' !~ 'd.*' |
!~* |
Does not match a regular expression (case-insensitive) | 'Abc' !~* 'a.*' |
Logical operators
Logical operators combine or manipulate conditions in a SQL query.
Operator | Meaning |
---|---|
AND |
Returns true if both operands are true. Otherwise, returns false. |
BETWEEN |
Returns true if the left operand is within the range of the right operand. |
EXISTS |
Returns true if the results of a subquery are not empty. |
IN |
Returns true if the left operand is in the right operand list. |
LIKE |
Returns true if the left operand matches the right operand pattern string. |
NOT |
Negates the subsequent expression. |
OR |
Returns true if any operand is true. Otherwise, returns false. |
Bitwise operators
Bitwise operators perform bitwise operations on bit patterns or binary numerals.
Operator | Meaning | Example | Result |
---|---|---|---|
& |
Bitwise and | 5 & 3 |
1 |
| |
Bitwise or | 5 | 3 |
7 |
^ |
Bitwise xor | 5 ^ 3 |
6 |
>> |
Bitwise shift right | 5 >> 3 |
0 |
<< |
Bitwise shift left | 5 << 3 |
40 |
Other operators
SQL supports other miscellaneous operators that perform various operations.
Operator | Meaning | Example | Result |
---|---|---|---|
|| |
Concatenate strings | 'Hello' || ' world' |
Hello world |
AT TIME ZONE |
Apply a time zone offset | View example |
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.