Updated on 2025-10-23 GMT+08:00

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.

Table 1 Operator description

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

Table 2 Data types

General Data Type

Type

Boolean Types

BOOLEAN/BOOL

Binary Types

BINARY, VARBINARY, TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB

Character Types

CHAR, VARCHAR, TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT

Date and Time Types

DATE, TIME, TIMESTAMP, DATETIME, and YEAR

Bit String Types

BIT

Numeric Types

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.

Table 3 Operator priority list

Associativity

Symbol

left

OR

left

XOR

left

AND

right

NOT

right

=

nonassoc

<, >, >=, and <=

nonassoc

LIKE

nonassoc

BETWEEN

nonassoc

IN

left

|

left

&

left

<< and >>

left

+ and -

left

*, /, %, DIV, and MOD

left

^

left

~

right

!