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?
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!