INTERVAL |
Intervalle |
|---|---|
| MySQL |
Syntaxe
| Interval(rechercher,argument[,...]) |
Paramètres
| Nom | Description |
|---|---|
| rechercher | Ce paramètre permet d'indiquer la valeur a rechercher dans la liste d'arguments. |
| argument | Ce paramètre permet d'indiquer la liste des valeurs d'intervalles dans lequel la recherche doit être effectué. |
Description
Cette fonction retourne la position qu'un nombre doit avoir dans une liste de données trié.
Exemple
Voici un exemple montrant une utilisation plus classique de cette fonction :
- SELECT 'Interval(0,0,5,10,15,20,25,30,35,40)=' As Text, Interval(0,0,5,10,15,20,25,30,35,40) As Result UNION
- SELECT 'Interval(5,0,5,10,15,20,25,30,35,40)=' As Text, Interval(5,0,5,10,15,20,25,30,35,40) As Result UNION
- SELECT 'Interval(10,0,5,10,15,20,25,30,35,40)=' As Text, Interval(10,0,5,10,15,20,25,30,35,40) As Result UNION
- SELECT 'Interval(15,0,5,10,15,20,25,30,35,40)=' As Text, Interval(15,0,5,10,15,20,25,30,35,40) As Result UNION
- SELECT 'Interval(20,0,5,10,15,20,25,30,35,40)=' As Text, Interval(20,0,5,10,15,20,25,30,35,40) As Result UNION
- SELECT 'Interval(25,0,5,10,15,20,25,30,35,40)=' As Text, Interval(25,0,5,10,15,20,25,30,35,40) As Result UNION
- SELECT 'Interval(45,0,5,10,15,20,25,30,35,40)=' As Text, Interval(45,0,5,10,15,20,25,30,35,40) As Result UNION
- SELECT 'Interval(-7,0,7,14,21,28)=' As Text, Interval(-7,0,7,14,21,28) As Result
on obtiendra le résultat suivant :
| Text | Result |
| Interval(0,0,5,10,15,20,25,30,35,40)= | 1 |
| Interval(5,0,5,10,15,20,25,30,35,40)= | 2 |
| Interval(10,0,5,10,15,20,25,30,35,40)= | 3 |
| Interval(15,0,5,10,15,20,25,30,35,40)= | 4 |
| Interval(20,0,5,10,15,20,25,30,35,40)= | 5 |
| Interval(25,0,5,10,15,20,25,30,35,40)= | 6 |
| Interval(45,0,5,10,15,20,25,30,35,40)= | 9 |
| Interval(-7,0,7,14,21,28)= | 0 |
Voir également
Article - Les géants de l'informatique - Oracle
Références
MySQL - Référence, Edition Micro Application, Nicolas Rivereau, Antoine Pichot, 2002, ISBN: 2-7429-2560-0, page 927.
MySQL: The definitive guide to using, programming, and administering MySQL 4 databases - Second Edition, Paul Dubois, 2003, ISBN: 0-7357-1212-3, page 801
Dernière mise à jour : Mercredi, le 29 avril 2015