DIV

You are viewing an old version of this article. View the current version here.

Sintaxe

DIV

Descrição

Divisão inteira.Similar a FLOOR(), porém é seguro com valores BIGINT. Resultados incorretos podem ocorrer para operandos não inteiros que excedam a faixa de BIGINT.

Se o modo ERROR_ON_DIVISION_BY_ZERO SQL_MODE é utilizado, a divisão por zero produx um erro. De outra forma, é retornado NULL.

O resto de uma divisão pode ser obtido utilizando o operador MOD.

Exemplos

SELECT 300 DIV 7;
+-----------+
| 300 DIV 7 |
+-----------+
|        42 |
+-----------+

SELECT 300 DIV 0;
+-----------+
| 300 DIV 0 |
+-----------+
|      NULL |
+-----------+

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.