%,MOD
Description
The %,MOD operator is used for modulo operation. Returns the remainder of N divided by M. For more information.
Syntax
1. > SELECT N % M, N MOD M;
Examples
1. mysql> select 12 mod 5;
2. +--------+
3. | 12 % 5 |
4. +--------+
5. | 2 |
6. +--------+
7. 1 row in set (0.00 sec)
1. create table t2(c1 int, c2 int);
2. insert into t2 values (-3, 2);
3. insert into t2 values (1, 2);
5. mysql> select c1 mod 2 from t2;
6. +--------+
7. | c1 % 2 |
8. +--------+
9. | -1 |
10. | 1 |
11. +--------+
12. 2 rows in set (0.01 sec)
14. mysql> select c1 mod c2 from t2;
15. +---------+
16. | c1 % c2 |
17. +---------+
18. | -1 |
19. | 1 |
20. +---------+
21. 2 rows in set (0.01 sec)
