This is a read-only copy of the MariaDB Knowledgebase generated on 2024-05-02. For the latest, interactive version please visit https://mariadb.com/kb/.

DIV

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 |
+-----------+
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.