A list of the more useful numeric functions is shown in Table 8.4. There are many more in the manual. Table 8.4. Numeric Functions
Let's look at an example using mod() and div . One confusing thing about these functions is that whereas mod can be expressed as mod(9,2) or 9 mod 2 or even 9 % 2 the div function can be expressed only as 9 div 2 So, for example, div(9, 2) will not work and will give a syntax error. Running mod and div in MySQL gives the following results: mysql> select 9 mod 2; +---------+ 9 mod 2 +---------+ 1 +---------+ 1 row in set (0.00 sec) mysql> select 9 div 2; +---------+ 9 div 2 +---------+ 4 +---------+ 1 row in set (0.00 sec) |