/
Division operator. Dividing by zero will return NULL. By default, returns four digits after the decimal. This is determined by the server system variable div_precision_increment which by default is four. It can be set from 0 to 30.
Dividing by zero returns NULL
. If the ERROR_ON_DIVISION_BY_ZERO
SQL_MODE is used (the default since MariaDB 10.2.4), a division by zero also produces a warning.
SELECT 4/5; +--------+ | 4/5 | +--------+ | 0.8000 | +--------+ SELECT 300/(2-2); +-----------+ | 300/(2-2) | +-----------+ | NULL | +-----------+ SELECT 300/7; +---------+ | 300/7 | +---------+ | 42.8571 | +---------+
Changing div_precision_increment for the session from the default of four to six:
SET div_precision_increment = 6; SELECT 300/7; +-----------+ | 300/7 | +-----------+ | 42.857143 | +-----------+ SELECT 300/7; +-----------+ | 300/7 | +-----------+ | 42.857143 | +-----------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/division-operator/