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
NisNULL, returnsNULL. -
If
Nis 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,
Nis greater than or equal to Nm, butNis less than Nn+1, returns n. (If NmisNULL, it is also considered thatNis 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)