
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Display matching repeated date records only once in MySQL
Let’s say we are finding records matching with the current date. Since we want repeated matching records only once, use LIMIT.
For example, the current date is −
2019-10-02
Let us first create a table −
mysql> create table DemoTable1450 -> ( -> DueDate date -> ); Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1450 values('2019-09-30'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1450 values('2019-10-02'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1450 values('2019-10-02'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1450 values('2019-10-02'); Query OK, 1 row affected (0.30 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1450;
This will produce the following output −
+------------+ | DueDate | +------------+ | 2019-09-30 | | 2019-10-02 | | 2019-10-02 | | 2019-10-02 | +------------+ 4 rows in set (0.00 sec)
Following is the query to display repeated matching date only once −
mysql> select * from DemoTable1450 where DueDate=curdate() limit 1;
This will produce the following output −
+------------+ | DueDate | +------------+ | 2019-10-02 | +------------+ 1 row in set (0.00 sec)
- Related Articles
- Matching Only Once in Perl
- Display records after a particular date in MySQL
- Display only date from timestamp value in MySQL
- Display all records ignoring the current date record in MySQL
- Find and display duplicate values only once from a column in MySQL
- Display distinct dates in MySQL from a column with date records
- Implement MySQL IN for 2 columns to display only selected records
- How to compare Year, Month and Day in a MySQL query and display matching records
- How to display coming Sunday's date for all the date records in MySQL?
- MySQL regexp to display only records with strings or strings mixed with numbers. Ignore only the number records
- MySQL query to display only the records that contains single word?
- MySQL query to subtract date records with week day and display the weekday with records
- Display records from the current date till rest of the same month in MySQL?
- Display records ignoring NULL in MySQL
- Display month names and year from a column with date records with MySQL

Advertisements