Name

INTERVAL( )

Synopsis

INTERVAL(search, column,  . . . )

This function returns the index of the value of the string or column given in the first argument for where it would be located in the list of strings or columns given in subsequent arguments, which must be listed from lowest to highest. If the search element would be located before the first element, 0 is returned. All arguments are treated as integers.

SELECT INTERVAL('4', '1','3','5','7','9');
+------------------------------------+
| INTERVAL('4', '1','3','5','7','9') |
+------------------------------------+
|                                  2 |
+------------------------------------+

In this example, the value of 4 would fall after the second position, after the 3 in the list.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.