Home  >  Article  >  Database  >  What will MySQL return if I use a closed unit value set with the INTERVAL keyword?

What will MySQL return if I use a closed unit value set with the INTERVAL keyword?

WBOY
WBOYforward
2023-08-29 14:01:02949browse

如果我使用带有 INTERVAL 关键字的封闭单位值集,MySQL 将返回什么?

In this case, MySQL will consider the first of the two values ​​provided in the accompanying unit value set. It returns output, along with warnings, after calculating the interval based on the values ​​considered in the closed set, in the units given in the INTERVAL keyword.

The following examples will clarify this -

mysql> Select TIMESTAMP('2017-10-22 04:05:36' + INTERVAL '4 2' Hour)AS 'HOUR VALUE INCREASED BY 4';
+---------------------------+
| HOUR VALUE INCREASED BY 4 |
+---------------------------+
| 2017-10-22 08:05:36       |
+---------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> Show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '4 2' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

The above is the detailed content of What will MySQL return if I use a closed unit value set with the INTERVAL keyword?. 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