For the complete documentation index, see llms.txt. This page is also available as Markdown.

INTERVAL

Syntax

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

Description

Returns the index of the last argument that is less than or equal to the first argument, or is NULL.

Returns 0 if N0 < N1, 1 if N1 <= N0 < N2, 2 if N2 <= N0 < N3 and so on or -1 if N0 is NULL. All arguments are treated as integers. It is required that N1 <= N2 <= N3 <= ... <= Nn for this function to work correctly because a fast binary search is used.

Examples

SELECT INTERVAL(22, 24, 26, 28);
+--------------------------+
| INTERVAL(22, 24, 26, 28) |
+--------------------------+
|                        0 |
+--------------------------+
SELECT INTERVAL(22, 22, 22, 22, 23);
+------------------------------+
| INTERVAL(22, 22, 22, 22, 23) |
+------------------------------+
|                            3 |
+------------------------------+

This page is licensed: GPLv2, originally from fill_help_tables.sql

spinner

Last updated

Was this helpful?