

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I use MySQL INTERVAL() function with a column of a table?
We can use INTERVAL() function with a column of a table by providing the first argument as the name of the column. In this case, al the values in that column would be compared with the values given as the other arguments of INTERVAL() function and on that basis of comparison, the result set is provided. To understand it, the data from the employee table is used which is as follows −
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 of ID = 4 to 8 as the INTERVAL function has greater than 0 values for these rows.
- Related Questions & Answers
- How can we use MySQL EXPORT_SET() function with column of a table?
- How can we add a time interval to date stored in a column of MySQL table?
- How can I use INTERVAL keyword with MySQL NOW() and CURDATE() functions?
- How can I use SPACE() function along with MySQL’s column data?
- How can I create a MySQL table with a column with only 3 possible given values?
- How can I use another MySQL function/s with REPEAT() function?
- How can I drop an existing column from a MySQL table?
- How can I remove every column in a table in MySQL?
- How can I update MySQL table after quoting the values of a column with a single quote?
- How can I use the arithmetic operators (+,-,*,/) with unit values of INTERVAL keyword in MySQL?
- How can I use SPACE() function with MySQL WHERE clause?
- How to use REPLACE() function with column’s data of MySQL table?
- How can we use INSERT() function to insert a new string into the value of a column of MySQL table?
- Can we use INTERVAL keyword while inserting date records in a MySQL table?
- How can I change the name of an existing column from a MySQL table?
Advertisements