MySQL: DIV Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL DIV Function

In this guide, we will explain how to use the MySQL DIV function with syntax and examples.

Description

The MySQL DIV function is used for integer division where n is divided by m and an integer value is returned.

Syntax

The syntax for the DIV function in MySQL is:

n DIV m

Parameters or Arguments

n

The value that will be divided by m.mThe value that will be divided into n.

Note

  • The DIV function will return the result as an integer value.
  • The DIV function can be used with BIGINT values.
  • See also the FLOOR function.

Applies To

The DIV function can be used in the following versions :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some DIV function examples and explore how to use the DIV function.

For example:

mysql> SELECT 9 DIV 2;
Result: 4

mysql> SELECT 8 DIV 2;
Result: 4

mysql> SELECT 10.5 DIV 3.1;
Result: 3

mysql> SELECT 10.5 DIV -3.1;
Result: -3

Next Topic : Click Here

This Post Has One Comment

Leave a Reply