©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The MOD SQL Function in MySQL and MariaDB - Remainder of division

MODSyntax:MOD(Number, Divider)
Return value:FLOAT
Function type:Numeric function
Function Description

The MOD() function returns the remainder of "Number" divided by "Divider".

Synonymous can also be written "Number % Divider" or "Number MOD Divider".

If the ERROR_FOR_DIVISION_BY_ZERO in the system variable SQL_MODE is active, a "Divider" with the value 0 will generate an error, otherwise NULL will be returned.

If any of the arguments is NULL, the function returns NULL.

The integer part of a division can be get with "Number DIV Divider".

SQL Examples for the MOD function

 1
 2
 3
 4
 5
 6
 7
 8

select mod(10,1.5);
select 10 % 1.5;
select 10 mod 1.5;
select 10-((10 div 1.5)*1.5);
select mod(2,null);
select mod(2,0);

mod(10,1.5)
decimal(4)
1.0
10 % 1.5
decimal(4)
1.0
10 mod 1.5
decimal(4)
1.0
10-((10 div 1.5)*1.5)
decimal(6)
1.0
mod(2,null)
double(17)
NULL
mod(2,0)
int(1)
NULL
The examples were created with the MyWAY SQL manager: Download
MySQL SQL_MODE
Set ERROR_FOR_DIVISION_BY_ZERO in SQL_MODE
Mehr: Edit System variables

How to use the MOD() function in MySQL and MariaDB databases

The MOD() function in MySQL and MariaDB returns the remainder after dividing the first number by the second number. The function is used when performing operations based on remainders, for example to determine if a number is even or odd, to generate sequences, or to group values ​​based on a module condition.
MIDMINMINUTEMODMONTHMONTHNAMENAME_CONST

Further MySQL und MariaDB SQL Numeric functions

BIT_COUNTBIT_COUNT(Integer)
More about BIT_COUNT Function

CEILCEIL(Number)
More about CEIL Function

CEILINGCEILING(Number)
More about CEILING Function

CRC32CRC32(String)
More about CRC32 Function

CRC32CCRC32C([Parameter], String)

FLOORFLOOR(Number)
More about FLOOR Function

SIGNSIGN(Number)
More about SIGN Function

ABSABS(Number)
More about ABS Function

ACOSACOS(Number)
More about ACOS Function

ASINASIN(Number)
More about ASIN Function

ATANATAN(Number [, Number2])
More about ATAN Function

ATAN2ATAN2(Number [, Number2])
More about ATAN2 Function

COSCOS(Number)
More about COS Function

COTCOT(Number)
More about COT Function

DEGREESDEGREES(Number)
More about DEGREES Function

EXPEXP(Number)
More about EXP Function

LNLN(Number)
More about LN Function

LOGLOG([Base], Number)
More about LOG Function

LOG10LOG10(Number)
More about LOG10 Function

LOG2LOG2(Number)
More about LOG2 Function

POWPOW(Number, Exponent)
More about POW Function

POWERPOWER(Number, Exponent)
More about POWER Function

PIPI()
More about PI Function

RADIANSRADIANS(Number)
More about RADIANS Function

RANDRAND([Number])
More about RAND Function

ROUNDROUND(Number [, Decimals])
More about ROUND Function

SINSIN(Number)
More about SIN Function

SQRTSQRT(Number)
More about SQRT Function

TANTAN(Number)
More about TAN Function

TRUNCATETRUNCATE(Number, Decimals)
More about TRUNCATE Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the MOD SQL function: mariadb.com and w3schools.com
Updated: 2023-09-24ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer