

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is MySQL INTERVAL() function?
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.
- Related Questions & Answers
- What MySQL returns if the first argument of INTERVAL() function is NULL?
- What is MySQL ELT() function?
- What is MySQL MAKE_SET() function?
- What is MySQL OCTET_LENGTH() function?
- What is Nyquist Rate and Nyquist Interval?
- Why is it good to write the numbers in MySQL INTERVAL() function in ascending order?
- What is MySQL HEX() function and how it is different from CONV() function?
- What is the use of MySQL FROM_UNIXTIME() function?
- What is the use of MySQL GET_FORMAT() function?
- What is the use of MySQL LAST_INSERT_ID() function?
- What is the use of MySQL CONCAT_WS() function?
- What is the use of MySQL TRUNCATE() function?
- What is the use of MySQL UNHEX() function?
- What is the use of MySQL SUBSTRING_INDEX() function?
- What is the purpose of MySQL TRIM() function?
Advertisements