All pages
Powered by GitBook
1 of 1

Loading...

Division Operator (/)

Syntax

Description

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 default ERROR_ON_DIVISION_BY_ZERO is used, a division by zero also produces a warning.

Examples

Changing for the session from the default of four to six:

See Also

This page is licensed: GPLv2, originally from

/
Multiplication Operator (*)
  • truncate()

  • Operator Precedence

  • DIV function

  • SQL_MODE
    div_precision_increment
    Type Conversion
    Module operator (%)
    Addition Operator (+)
    Subtraction Operator (-)
    fill_help_tables.sql
    SELECT 4/5;
    +--------+
    | 4/5    |
    +--------+
    | 0.8000 |
    +--------+
    
    SELECT 300/(2-2);
    +-----------+
    | 300/(2-2) |
    +-----------+
    |      NULL |
    +-----------+
    
    SELECT 300/7;
    +---------+
    | 300/7   |
    +---------+
    | 42.8571 |
    +---------+
    SET div_precision_increment = 6;
    
    SELECT 300/7;
    +-----------+
    | 300/7     |
    +-----------+
    | 42.857143 |
    +-----------+
    
    SELECT 300/7;
    +-----------+
    | 300/7     |
    +-----------+
    | 42.857143 |
    +-----------+