
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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.
Advertisements