MySQL DIV Operator

In MySQL, the DIV operator computes the division of two integers and returns an integer result.

DIV Syntax

Here is the syntax of MySQL DIV operators:

x DIV y

Parameters

x
Required. A value that will be divided.
y
Required. The divisor.

Return value

x DIV y returns the integer value of the division (x is divided by y).

If x or y is not an integer, they will be converted to DECIMAL type before calculation.

DIV Examples

SELECT
    10 DIV 3,
    10 / 3,
    FLOOR(10/3),
    9.8 DIV 2.6,
    9.8 / 2.6,
    FLOOR(9.8/2.6)\G

output

*************************** 1\. row ***************************
      10 DIV 3: 3
        10 / 3: 3.3333
   FLOOR(10/3): 3
   9.8 DIV 2.6: 3
     9.8 / 2.6: 3.76923
FLOOR(9.8/2.6): 3

Here, We use the FLOOR() function to facilitate comparison of operation results.