Display records after a particular date in MySQL

MySQLMySQLi Database

Let us first create a table −

mysql> create table DemoTable708 (
   CustomerName varchar(100),
   ShippingDate date
);
Query OK, 0 rows affected (0.51 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable708 values('John','2019-01-21');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable708 values('Chris','2019-03-24');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable708 values('Robert','2019-04-26');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable708 values('David','2019-07-22');
Query OK, 1 row affected (0.17 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable708;

This will produce the following output -

+--------------+--------------+
| CustomerName | ShippingDate |
+--------------+--------------+
| John         | 2019-01-21   |
| Chris        | 2019-03-24   |
| Robert       | 2019-04-26   |
| David        | 2019-07-22   |
+--------------+--------------+
4 rows in set (0.00 sec)

Following is the query to display records after a particular date in MySQL −

mysql> select *from DemoTable708 where ShippingDate >='2019-04-01';

This will produce the following output -

+--------------+--------------+
| CustomerName | ShippingDate |
+--------------+--------------+
| Robert       | 2019-04-26   |
| David        | 2019-07-22   |
+--------------+--------------+
2 rows in set (0.00 sec)
raja
Published on 21-Aug-2019 12:12:22
Advertisements