If the first parameter of the INTERVAL() function is NULL, MySQL will return -1 as output. The following example will demonstrate it -
mysql> Select INTERVAL(NULL,20,32,38,40,50,55); +--------------------------------------+ | INTERVAL(NULL,20,32,38,40,50,55) | +--------------------------------------+ | -1 | +--------------------------------------+ 1 row in set (0.00 sec)
It will return -1 even if any other parameter along with the first parameter is NULL.
mysql> Select INTERVAL(NULL,20,32,NULL,40,50,NULL); +--------------------------------------+ | INTERVAL(NULL,20,32,NULL,40,50,NULL) | +--------------------------------------+ | -1 | +--------------------------------------+ 1 row in set (0.00 sec)
If the first argument is not NULL, and any one or more of the other arguments are NULL, then it returns the index value of the larger number, if any.
mysql> Select INTERVAL(50,20,NULL,55,40,50,NULL); +------------------------------------+ | INTERVAL(50,20,NULL,55,40,50,NULL) | +------------------------------------+ | 2 | +------------------------------------+ 1 row in set (0.00 sec)
The above is the detailed content of What will MySQL return if the first parameter of the INTERVAL() function is NULL?. For more information, please follow other related articles on the PHP Chinese website!