All pages
Powered by GitBook
1 of 1

Loading...

DIV

Perform integer division. This operator divides one number by another and returns the integer result, discarding any remainder.

Syntax

DIV

Description

Integer division. Similar to FLOOR(), but is safe with BIGINT values. Incorrect results may occur for non-integer operands that exceed the BIGINT range.

If the ERROR_ON_DIVISION_BY_ZERO is used, a division by zero produces an error. Otherwise, it returns NULL.

The remainder of a division can be obtained using the operator.

Examples

See Also

This page is licensed: GPLv2, originally from

SQL_MODE
MOD
Division operator
Operator Precedence
fill_help_tables.sql
SELECT 300 DIV 7;
+-----------+
| 300 DIV 7 |
+-----------+
|        42 |
+-----------+

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