# What is MySQL INTERVAL() function?

MySQLMySQLi Database

MySQL INTERVAL() function returns the index value of the argument which is greater than the first argument.

## Syntax

INTERVAL(N,N1,N2,N3,…)


Here, this function will compare 1st argument i.e. N with the other arguments i.e. N1, N2, N3 and so on. All the arguments are treated as integers. It returns the output as follows −

• If N<N1 then it returns 0
• If N<N2 then it returns 1
• If N<N3 then it returns 2 and so on…

The indexing is started with 2nd number i.e. from N1 and the first position is 0.

## Example

mysql> Select INTERVAL(50,20,32,38,40,50,55);
+--------------------------------+
| INTERVAL(50,20,32,38,40,50,55) |
+--------------------------------+
|                              5 |
+--------------------------------+
1 row in set (0.00 sec)


The above result set has 5 as its output because the index value of 55, which is the only greater number than 50, is 5.

Updated on 30-Jul-2019 22:30:21