Home  >  Article  >  Database  >  What will MySQL return if I write only one value in the enclosing unit value set of the compound INTERVAL unit?

What will MySQL return if I write only one value in the enclosing unit value set of the compound INTERVAL unit?

WBOY
WBOYforward
2023-08-26 21:41:111286browse

如果我只在复合 INTERVAL 单位的封闭单位值集中写入一个值,MySQL 将返回什么?

In this case, MySQL will consider the rightmost unit given in the compound INTERVAL unit. It returns the output after calculating an interval based on a single value provided in the attached unit value set. The following example will clarify it -

mysql> Select TIMESTAMP('2017-10-22 04:05:36' + INTERVAL '2 ' year_month) AS 'Only Month Value Changed';
+--------------------------+
| Only Month Value Changed |
+--------------------------+
| 2017-12-22 04:05:36      |
+--------------------------+
1 row in set (0.00 sec)

The above query changes the month (rightmost in the compound INTERVAL unit) from 10 to 12 based on a single value i.e. 2 provided in the accompanying unit value set.

The above is the detailed content of What will MySQL return if I write only one value in the enclosing unit value set of the compound INTERVAL unit?. 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