INTERVAL

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

Sintassi

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

Spiegazione

Restituisce 0 se N < N1, 1 se N < N2 e così via, oppure -1 se N è NULL. Tutti gli argomenti sono trattati come interi. Perché questa funzione si comporti correttamente è necessario che N1 < N2 < N3 < ... < Nn. Questo perché viene usata la ricerca binaria (molto veloce).

Esempi

MariaDB [(none)]> SELECT INTERVAL(23, 1, 15, 17, 30, 44, 200);
+--------------------------------------+
| INTERVAL(23, 1, 15, 17, 30, 44, 200) |
+--------------------------------------+
|                                    3 |
+--------------------------------------+
1 row in set (0.01 sec)

MariaDB [(none)]> SELECT INTERVAL(10, 1, 10, 100, 1000);
+--------------------------------+
| INTERVAL(10, 1, 10, 100, 1000) |
+--------------------------------+
|                              2 |
+--------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> SELECT INTERVAL(22, 23, 30, 44, 200);
+-------------------------------+
| INTERVAL(22, 23, 30, 44, 200) |
+-------------------------------+
|                             0 |
+-------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> 

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.