- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Select a column if condition is met in MySQL to fetch records from current date and current date + 1
Let us first get the current date −
mysql> select curdate();
This will produce the following output −
+------------+ | curdate() | +------------+ | 2019-12-15 | +------------+ 1 row in set (0.00 sec)
Let us first create a table −
mysql> create table DemoTable1956 ( ProductId int, ProductName varchar(20), CustomerName varchar(20), ShippingDate date ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1956 values(101,'Product-1','Sam','2019-10-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1956 values(102,'Product-2','Carol','2018-12-01'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1956 values(103,'Product-3','David','2019-12-15'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1956 values(104,'Product-4','Robert','2019-12-16'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1956;
This will produce the following output −
+-----------+-------------+--------------+--------------+ | ProductId | ProductName | CustomerName | ShippingDate | +-----------+-------------+--------------+--------------+ | 101 | Product-1 | Sam | 2019-10-11 | | 102 | Product-2 | Carol | 2018-12-01 | | 103 | Product-3 | David | 2019-12-15 | | 104 | Product-4 | Robert | 2019-12-16 | +-----------+-------------+--------------+--------------+ 4 rows in set (0.00 sec)
Here is the query to select a column and fetch current date and next date records −
mysql> select CustomerName from DemoTable1956 where ShippingDate IN(CURDATE(),CURDATE()+interval 1 Day);
This will produce the following output −
+--------------+ | CustomerName | +--------------+ | David | | Robert | +--------------+ 2 rows in set (0.00 sec)
- Related Articles
- Condition to check for due date and current date records in MySQL where clause
- Calling NOW() function to fetch current date records in MySQL?
- MySQL time period query to fetch date records from interval of 14 weeks from current date?
- Select dates between current date and 3 months from the current date in MySQL?
- Comparison of varchar date records from the current date in MySQL
- Fetch records from interval of past 3 days from current date in MySQL and add the corresponding records
- Fetch date records comparing with the current date’s day and month in MySQL
- Find the difference between current date and the date records from a MySQL table
- MySQL query to select date >= current date - 3 weeks?
- MySQL query to fetch date records greater than the current date after adding days with INTERVAL?
- How to update column values with date records and set 1 for corresponding records before the current date in SQL
- MySQL date column auto fill with current date?
- MySQL select * and find record with current date
- How to select rows in MySQL that are >= 1 DAY from the current date?
- How to select a date less than the current date with MySQL?

Advertisements