MOD : the remainder of a division between two numbers
Mod is a math function of MySQL which returns the reminder after a division. We will try to use this function in our query to get different results. Here are some examples.
SELECT MOD(100,20) // output is 0
SELECT MOD(52,25) //Output is 2
SELECT 24%7 //Output is 3
UPDATE student set address = concat(name,'_address') where MOD(id,2)=0
How SQL MOD() handles NULL value?
Here's a breakdown of how MOD() handles NULL data in various scenarios:
`MOD(NULL, number)`: If the first argument (dividend) is `NULL`, the result is `NULL`, indicating that the outcome of the operation cannot be determined because one of the inputs is unknown.
`MOD(number, NULL)`: If the second argument (divisor) is `NULL`, the result is also `NULL`, since dividing by an unknown quantity does not produce a determinable result.
`MOD(NULL, NULL)`: If both arguments are `NULL`, the result is `NULL`, because the operation involves two unknown values, making the outcome indeterminate.