Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2023-08-30 21:25:02
forward
486 people have browsed it

如果 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)
Copy after login

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!