ID EN
Arithmetic Operators

DIV

MySQL 8.4

Integer division. Discards from the division result any fractional part to the right of the decimal point.

Syntax

MYSQL
SELECT 5 DIV 2, -5 DIV 2, 5 DIV -2, -5 DIV -2;
2, -2, -2, 2

Examples

Example

If either operand has a noninteger type, the operands are converted to DECIMAL and divided using DECIMAL arithmetic before converting the result to BIGINT. If the result exceeds BIGINT range, an error occurs.

MYSQL
SELECT 5 DIV 2, -5 DIV 2, 5 DIV -2, -5 DIV -2;
2, -2, -2, 2