如果INTERVAL()
函数的第一个参数为NULL,则MySQL返回-1作为输出。以下示例将演示它-
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)
即使其他任何参数连同第一个参数一起为NULL,也将返回-1。
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)
如果第一个参数不为NULL,而另一个参数中的任何一个或多个为NULL,则它将返回更大数字的索引值(如果有)。
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)