MariaDB: MOD Function
This MariaDB tutorial explains how to use the MariaDB MOD function with syntax and examples.
Description
The MariaDB MOD function returns the remainder of n divided by m.
Syntax
The syntax for the MOD function in MariaDB is:
MOD( n, m )
OR
n MOD m
OR
n % m
Parameters or Arguments
- n
- The value that will be divided by m.
- m
- The value that will be divided into n.
Note
- The MOD function uses the formula of
n / m
and the remainder is what is returned. - The MOD function returns the exact remainder (without any rounding).
Applies To
The MOD function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB MOD function examples and explore how to use the MOD function in MariaDB.
For example:
SELECT MOD(11, 4); Result: 3 SELECT MOD(11, 0.49); Result: 0.22 SELECT MOD(11, 0.9832475); Result: 0.1842775
SELECT 11 MOD 4; Result: 3 SELECT 11 MOD 0.49; Result: 0.22 SELECT 11 MOD 0.9832475; Result: 0.1842775
SELECT 11 % 4; Result: 3 SELECT 11 % 0.49; Result: 0.22 SELECT 11 % 0.9832475; Result: 0.1842775
Advertisements