Home > Database > Mysql Tutorial > 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
Release: 2023-08-26 21:41:11
forward
1383 people have browsed it

如果我只在复合 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)
Copy after login

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!

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