SQL reference (MySQL and MariaDB dialects)

Operators

All operators Raft DB reads, grouped by kind, with the precedence table and the assignment operators.

An operator joins or changes values in an expression. This page lists them all and links to the page of each group.

Operators by group#

GroupOperatorsPage
Arithmetic+ - * / DIV % MOD, unary - and +Arithmetic and logical operators
Comparison= <=> <> != < <= > >= IS IS NOT BETWEEN IN EXISTS, ANY, SOME, ALL, row comparisonComparison operators
LogicalAND && OR || XOR NOT !Arithmetic and logical operators
Bit& | ^ ~ << >>Bit operators
StringLIKE NOT LIKE REGEXP RLIKE NOT REGEXP COLLATE BINARYString operators
JSON-> ->> MEMBER OF (MySQL dialect only)JSON operators
Assignment:= = (in SET and UPDATE)below
Date+ INTERVAL expr unit, - INTERVAL expr unitDate and time functions

Precedence#

From the tightest to the loosest. Operators on one row group left to right.

LevelOperators
1INTERVAL expr unit
2COLLATE, BINARY, ->, ->>, MEMBER OF
3unary -, +, ~
4^
5*, /, DIV, %, MOD
6-, +
7<<, >>
8&
9|
10=, <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN, BETWEEN
11NOT, !
12AND, &&
13XOR, OR, ||
14:=

Differences from MySQL's table: XOR is read at the level of OR; ! is read at the level of NOT; || is always OR; ^ binds tighter than * (as in MySQL). The details are on Expressions and operator precedence. Use parentheses where it matters.

Assignment operators#

SQL
SET @var = expr;            -- SET: = assigns
SET @var := expr;           -- := assigns
SELECT @var := expr;        -- := assigns inside a statement and gives the value
UPDATE t SET col = expr;    -- in UPDATE ... SET, = assigns

= assigns only in SET and in UPDATE ... SET; anywhere else it compares. := assigns to a user variable inside any expression (see Variables). The assignment to a column with := in UPDATE ... SET col := expr is read as well.

Remarks#

  • Dialect differences. The JSON operators exist in MySQL only, so the MariaDB dialect does not read them. || is OR in both dialects (MariaDB in PIPES_AS_CONCAT mode and in Oracle mode would concatenate; Raft DB does not).
  • Type of the result. A comparison or a logical operator gives INT 0, 1 or NULL; arithmetic follows Expressions and operator precedence.
  • Not supported yet: LIKE ... ESCAPE, SOUNDS LIKE, the full-text MATCH ... AGAINST (FULLTEXT keys are refused), the case-sensitive effect of BINARY.

Example#

SQL
SELECT 2 + 3 * 4, (2 + 3) * 4, 10 DIV 3, 10 % 3, 5 & 4, 1 << 3, 'a' = 'A', NULL <=> NULL;

See also#