Syntax
INTERVAL(N,N1,N2,N3,...)
Purpose
You can call this function to return the result of comparing N with a list of other arguments, such as N1, N2, and so forth. In this topic, N is compared with N~1~, N~2~, ...., and N~n~, which respectively represent N1, N2, ..., and Nn in the syntax.
N is compared with N~n~ in sequence:
If
Nis NULL, the return value is NULL.If
Nis less than N~1~, the return value is 0.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 (0.00 sec)
obclient> SELECT INTERVAL(23, 1, 15, 17, NULL, 44, 200);
+----------------------------------------+
INTERVAL(23, 1, 15, 17, NULL, 44, 200)
+----------------------------------------+
4
+----------------------------------------+
1 row in set (0.00 sec)
obclient> SELECT INTERVAL(23, 1, 15, 17, 30, 17, 200);
+--------------------------------------+
INTERVAL(23, 1, 15, 17, 30, 17, 200)
+--------------------------------------+
3
+--------------------------------------+
1 row in set (0.00 sec)