MySQL MOD() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL MOD() Function

❮ MySQL Functions

Example

Return the remainder of n divided by m:

SELECT MOD(18, 4);
Try it Yourself »

Definition and Usage

The MOD() function returns the remainder of n divided by m.

Syntax

MOD(n, m)

OR:

n MOD m

OR:

n % m

Parameter Values

Parameter Description
n Required. The value that will be divided by m
m Required. The value that will be divided into n

Technical Details

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

More Examples

Example

Return the remainder of n divided by m:

SELECT 18 MOD 4;
Try it Yourself »

Example

Return the remainder of n divided by m:

SELECT 18 % 4;
Try it Yourself »

❮ MySQL Functions