MOD

Sintaxe

MOD(N,M), N % M, N MOD M

Descrição

Operação módulo. Retorna o resto de N dividido por M. Veja também Modulo Operator.

Se a variável de sistema ERROR_ON_DIVISION_BY_ZERO SQL_MODE é utilizada, qualquer operação do tipo "número MOD zero" produz um erro. De outra forma, esta retorna NULL.

A parte intereira do resultado de uma divisão pode ser obtida utilizando DIV.

Exemplos

SELECT 1042 % 50;
+-----------+
| 1042 % 50 |
+-----------+
|        42 |
+-----------+

SELECT MOD(234, 10);
+--------------+
| MOD(234, 10) |
+--------------+
|            4 |
+--------------+

SELECT 253 % 7;
+---------+
| 253 % 7 |
+---------+
|       1 |
+---------+

SELECT MOD(29,9);
+-----------+
| MOD(29,9) |
+-----------+
|         2 |
+-----------+

SELECT 29 MOD 9;
+----------+
| 29 MOD 9 |
+----------+
|        2 |
+----------+

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.