Syntax
INTERVAL(N,N1,N2,N3,...)
Purpose
INTERVAL() returns the result of comparing N with a list of other arguments, such as N1,N2,.... In this topic, N is compared with N~1~, N~2~, …, N~n~, which respectively represent N1, N2, ..., and Nn in the syntax.
N is compared with N~n~ in sequence:
If
NisNULL,NULLis returned.If
Nis less than N~1~, 0 is returned.If a positive integer n satisfies that any positive integer m less than or equal to n results in
Nbeing greater than or equal to N~m~ but less than N~n+1~, n is returned. If N~m~ isNULL,Nis greater than or equal to N~m~.
Examples
obclient> SELECT INTERVAL(23, 1, 15, 17, 30, 44, 200);
+--------------------------------------+
| INTERVAL(23, 1, 15, 17, 30, 44, 200) |
+--------------------------------------+
| 3 |
+--------------------------------------+
1 row in set
obclient> SELECT INTERVAL(23, 1, 15, 17, NULL, 44, 200);
+----------------------------------------+
| INTERVAL(23, 1, 15, 17, NULL, 44, 200) |
+----------------------------------------+
| 4 |
+----------------------------------------+
1 row in set
obclient> SELECT INTERVAL(23, 1, 15, 17, 30, 17, 200);
+--------------------------------------+
| INTERVAL(23, 1, 15, 17, 30, 17, 200) |
+--------------------------------------+
| 3 |
+--------------------------------------+
1 row in set