#We can use the INTERVAL() function on a column of a table by providing the first parameter as the name of the column. In this case, all values in the column are compared with the values given as other parameters of the INTERVAL() function and the result set is provided based on the comparison. To understand it, use data from Employee table as shown below -
mysql> Select* from employee568; +----+--------+--------+ | ID | Name | Salary | +----+--------+--------+ | 1 | Gaurav | 50000 | | 2 | Rahul | 20000 | | 3 | Advik | 25000 | | 4 | Aarav | 65000 | | 5 | Ram | 20000 | | 6 | Mohan | 30000 | | 7 | Aryan | NULL | | 8 | Vinay | NULL | +----+--------+--------+ 8 rows in set (0.00 sec) mysql> Select * from employee WHERE INTERVAL(ID,4) > 0; +----+-------+--------+ | ID | Name | Salary | +----+-------+--------+ | 4 | Aarav | 65000 | | 5 | Ram | 20000 | | 6 | Mohan | 30000 | | 7 | Aryan | NULL | | 8 | Vinay | NULL | +----+-------+--------+ 5 rows in set (0.00 sec)
The above result set has 5 rows with ID = 4 to 8 because INTERVAL function has value greater than 0 for these rows.
The above is the detailed content of How to use the MySQL INTERVAL() function on a table's columns?. For more information, please follow other related articles on the PHP Chinese website!