MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Mod Operator

In MySQL Mod operator also known as Modulo operation, returns the remainder of N divided by M.

Note: The MOD operator uses the formula of n / m and remainder is returned.
Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

MySQL MOD OPERATOR Syntax

To perform Modulo operation and get remainder, use the following syntax:

Syntax

MOD( n, m );

OR

n MOD m;

OR

n % m;

Parameters:

n: The value that will be divided by m.

m: The value that will be divided into n.

MySQL DIV OPERATOR example

The following MySQL, MOD operator is used to perform Modulo operation and get remainder:

Example

SELECT MOD(11, 2);

OR

SELECT 13 MOD 5;

Note:

In the above example, we are performing Modulo operation and getting remainder value.

You can use MySQL Command Line Client to perform Modulo operation and get remainder value. It will look like this: