Operator Overview
Operators are used to concatenate operands or parameters and return results. In terms of syntax, operators can appear before operands, after operands, or between two operands. Therefore, operators can be classified into unary operators and binary operators.
- Unary operator
Operator Operand
- Binary operator
Operand 1 Operator Operand 2
Table 1 describes the operators supported in M-compatible databases.
|
Operation Type |
Operator Name |
Operand Type |
Description |
|---|---|---|---|
|
Logical operation |
NOT (!) |
Unary |
NOT. |
|
AND (&&) |
Binary |
AND. |
|
|
OR (||) |
Binary |
OR. |
|
|
XOR |
Binary |
XOR. |
|
|
Bitwise operation |
& |
Binary |
Bitwise AND. |
|
| |
Binary |
Bitwise OR. |
|
|
^ |
Binary |
Bitwise XOR. |
|
|
<< |
Binary |
Left shift. |
|
|
>> |
Binary |
Right shift. |
|
|
~ |
Unary |
Bitwise NOT. |
|
|
Pattern matching |
[NOT] LIKE |
Binary |
Simple pattern matching. |
|
Comparison operation |
< |
Binary |
Less than. |
|
> |
Binary |
Greater than. |
|
|
<= |
Binary |
Less than or equal to. |
|
|
>= |
Binary |
Greater than or equal to. |
|
|
= |
Binary |
Equal to. |
|
|
<> or != |
Binary |
Not equal to. |
|
|
<=> |
Binary |
NULL-safe equal. |
|
|
[NOT] BETWEEN AND |
Ternary |
Specifies whether operand 1 is greater than or equal to operand 2 and less than or equal to operand 3. |
|
|
IS |
Binary |
Specifies whether a value is equivalent to a Boolean value. |
|
|
IS NOT |
Binary |
Specifies whether a value is not equivalent to a Boolean value (negation of IS). |
|
|
IS NOT NULL |
Unary (operand operator) |
Specifies whether a value is not NULL. |
|
|
IS NULL |
Unary (operand operator) |
Specifies whether a value is NULL. |
|
|
Arithmetic operation |
+ |
Unary/Binary |
Unary indicates a positive number, and binary indicates addition. |
|
- |
Unary/Binary |
Unary indicates negative, and binary indicates subtraction. |
|
|
* |
Binary |
Multiplication operator. |
|
|
/ |
Binary |
Division operator. |
|
|
% or MOD |
Binary |
Returns the remainder after integer division. |
|
|
DIV |
Binary |
Returns the quotient value after integer division. |
|
|
Type conversion |
BINARY |
Unary |
Converts to the BINARY type. |
Data Types Supported by Operators
|
General Data Type |
Type |
|---|---|
|
BOOLEAN/BOOL |
|
|
BINARY, VARBINARY, TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB |
|
|
CHAR, VARCHAR, TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT |
|
|
DATE, TIME, TIMESTAMP, DATETIME, and YEAR |
|
|
BIT |
|
|
TINYINT, SMALLINT, MEDIUMINT, INT/INTEGER, BIGINT, NUMERIC/DECIMAL, DEC, FIXED, FLOAT, FLOAT4, FLOAT8, DOUBLE, TINYINT UNSIGNED, SMALLINT UNSIGNED, MEDIUMINT UNSIGNED, INT/INTEGER UNSIGNED, and BIGINT UNSIGNED |
For details about data types, see Data Types.
Operator Priority
Operators have higher priorities from top to bottom. Operators in the same row have the same priority. For details, see Table 3.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot