What MySQL returns if I use enclosed set of unit values with INTERVAL keyword?

MySQLMySQLi Database

In this case, MySQL will take into consideration the first value out of two provided in the enclosed set of unit values. It will return the output along with warning after calculating the interval, based on the considered value from an enclosed set, on the unit given in INTERVAL keyword. 

The following example will clarify it −

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)
raja
Published on 19-Feb-2018 15:35:45
Advertisements