Home  >  Article  >  Database  >  What will MySQL return if the first parameter of the INTERVAL() function is NULL?

What will MySQL return if the first parameter of the INTERVAL() function is NULL?

WBOY
WBOYforward
2023-08-30 21:25:02520browse

如果 INTERVAL() 函数的第一个参数为 NULL,MySQL 将返回什么?

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete