
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
What MySQL returns if I write only one value in the enclosed set of unit values for compound INTERVAL unit?
In this case, MySQL will take into consideration right most unit given in compound INTERVAL unit. It will return the output after calculating the interval on the basis of single value provided in the enclosed set of unit values. 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 query above changes the month (right most in compound INTERVAL unit) from 10 to 12 based on the single value i.e. 2 provided in the enclosed set of unit values.
- Related Articles
- What MySQL returns if I use enclosed set of unit values with INTERVAL keyword?
- How to use compound INTERVAL unit in MySQL?
- How can I use the arithmetic operators (+,-,*,/) with unit values of INTERVAL keyword in MySQL?
- What are the different unit values that can be used with MySQL INTERVAL keyword?
- Set value only for NULL values in a MySQL table
- What MySQL returns if I insert invalid value into ENUM?
- What MySQL returns if the first argument of INTERVAL() function is NULL?
- How can I set 0 if a query returns a null value in MySQL?
- What MySQL returns if sub-query, used to assign new values in the SET clause of UPDATE statement, returns no rows?
- What MySQL returns if sub-query, used to assign new values in the SET clause of UPDATE statement, returns multiple rows?
- Display only the default values set for columns in MySQL
- Write the C.G.S unit of force.
- Write the SI unit of impulse.
- Write the common unit of density.
- Write the SI unit of distance.

Advertisements