W3cubDocs

/MariaDB

Operators

Operators can be used for comparing values or for assigning values. There are several operators and they may be used in different SQL statements and clauses. Some can be used somewhat on their own, not within an SQL statement clause.

For comparing valuesstring or numericyou can use symbols such as the equal-sign (i.e., =) or the exclamation point and the equal-sign together (i.e., !=). You might use these in WHERE clauses or within a flow-control statement or function (e.g., IF( )). You can also use basic regular expressions with the LIKE operator.

For assigning values, you can also use the equal-sign or other arithmetic symbols (e.g. plus-sign). You might do this with the SET statement or in a SET clause in an UPDATE statement.

Title Description

Arithmetic Operators

Title Description
Addition Operator (+) Addition.
DIV Integer division.
Division Operator (/) Division.
MOD Modulo operation. Remainder of N divided by M.
Modulo Operator (%) Modulo operator. Returns the remainder of N divided by M.
Multiplication Operator (*) Multiplication.
Subtraction Operator (-) Subtraction and unary minus.

Assignment Operators

Title Description
Assignment Operator (:=) Assignment operator for assigning a value.
Assignment Operator (=) The equal sign as an assignment operator.

Other Operators Articles

Title Description
Bit Functions and Operators Operators for comparison and setting of values, and related functions.

Comparison Operators

Title Description
!= Not equal operator.
< Less than operator.
<= Less than or equal operator.
<=> NULL-safe equal operator.
= Equal operator.
> Greater than operator.
>= Greater than or equal operator.
BETWEEN AND True if expression between two values.
COALESCE Returns the first non-NULL parameter
GREATEST Returns the largest argument.
IN True if expression equals any of the values in the list
INTERVAL Index of the argument that is less than the first argument
IS Tests whether a boolean is TRUE, FALSE, or UNKNOWN
IS NOT Tests whether a boolean value is not TRUE, FALSE, or UNKNOWN
IS NOT NULL Tests whether a value is not NULL
IS NULL Tests whether a value is NULL
ISNULL Checks if an expression is NULL
LEAST Returns the smallest argument.
NOT BETWEEN Same as NOT (expr BETWEEN min AND max)
NOT IN Same as NOT (expr IN (value,...))

Logical Operators

Title Description
! Logical NOT.
&& Logical AND.
XOR Logical XOR.
|| Logical OR.
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.

© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/operators/