 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Fetch the count of a specific date in a MySQL table
Let us first create a table −
mysql> create table DemoTable1946 ( ShippingDate date ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1946 values('2019-12-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1946 values('2018-12-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1946 values('2017-12-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1946 values('2019-04-22'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1946 values('2019-12-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1946 values('2015-12-11'); Query OK, 1 row affected (0.00 sec) Display all records from the table using select statement −
mysql> select * from DemoTable1946;
This will produce the following output −
+--------------+ | ShippingDate | +--------------+ | 2019-12-11 | | 2018-12-11 | | 2017-12-11 | | 2019-04-22 | | 2019-12-11 | | 2015-12-11 | +--------------+ 6 rows in set (0.00 sec)
Here is the query to count a specific date −
mysql> select count(*) from DemoTable1946 where date(ShippingDate)='2019-12-11';
This will produce the following output −
+----------+ | count(*) | +----------+ | 2 | +----------+ 1 row in set (0.00 sec)
Advertisements
 