Skip to main content
Version: V1.0.0

INTERVAL

Syntax

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

Description

Returns the comparison result of N with the list N1,N2,.... In this description, N1, N2, ..., Nn represent the parameters N1,N2...,Nn.

Compare N with Nn in sequence:

  • If N is NULL, returns NULL.

  • If N is less than N1, returns 0.

  • If there exists a positive integer n such that for any positive integer m less than or equal to n, N is greater than or equal to Nm, but N is less than Nn+1, returns n. (If Nm is NULL, it is also considered that N is greater than or equal to Nm).

Examples

SELECT INTERVAL(23, 1, 15, 17, 30, 44, 200);
+--------------------------------------+
| INTERVAL(23, 1, 15, 17, 30, 44, 200) |
+--------------------------------------+
| 3 |
+--------------------------------------+
1 row in set (0.001 sec)

SELECT INTERVAL(23, 1, 15, 17, NULL, 44, 200);
+----------------------------------------+
| INTERVAL(23, 1, 15, 17, NULL, 44, 200) |
+----------------------------------------+
| 4 |
+----------------------------------------+
1 row in set (0.001 sec)

SELECT INTERVAL(23, 1, 15, 17, 30, 17, 200);
+--------------------------------------+
| INTERVAL(23, 1, 15, 17, 30, 17, 200) |
+--------------------------------------+
| 3 |
+--------------------------------------+
1 row in set (0.001 sec)