Math Numeric Functions MySQL Tutorial

MOD() also works on values that have a fractional part and returns the exact remainder after division:

mysql>
mysql> SELECT MOD(34.5,3);
+-------------+
| MOD(34.5,3) |
+-------------+
|         1.5 |
+-------------+
1 row in set (0.00 sec)
mysql>

mysql>
mysql> select MOD(3,0);
+----------+
| MOD(3,0) |
+----------+
|     NULL |
+----------+
1 row in set (0.00 sec)
mysql>