ID EN
Comparison Functions and Operators

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

MySQL 8.4

Returns 0 if N ≤ N1, 1 if N ≤ N2 and so on, or -1 if N is NULL. All arguments are treated as integers. It is required that N1 ≤ N2 ≤ N3 ≤ ... ≤ Nn for this function to work correctly. This is because a binary search is used (very fast).

Syntax

MYSQL
SELECT INTERVAL(23, 1, 15, 17, 30, 44, 200);
3
SELECT INTERVAL(10, 1, 10, 100, 1000);
2
SELECT INTERVAL(22, 23, 30, 44, 200);
0

Examples

Example
MYSQL
SELECT INTERVAL(23, 1, 15, 17, 30, 44, 200);
3
SELECT INTERVAL(10, 1, 10, 100, 1000);
2
SELECT INTERVAL(22, 23, 30, 44, 200);
0