Name
MOD()
Synopsis
MOD(number
,number
)number
MODnumber
This function returns the remainder of a number given in the
first argument when divided by the number given in the second
argument, the modulo. The function works the same as using the
%
operator between two given numbers. The second
syntax shown is available as of version 4.1 of MySQL. Starting with
version 4.1.7, fractional values may be given. Here is an
example:
SELECT MOD(10, 3); +------------+ | MOD(10, 3) | +------------+ | 1 | +------------+
Here’s an example of the alternate syntax:
SELECT 10 MOD 3; +----------+ | 10 MOD 3 | +----------+ | 1 | +----------+
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.