
- 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
Update record on a specific date matching the current date in MySQL
Let us first create a table −
mysql> create table DemoTable1822 ( Amount int, DueDate date ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1822 values(1000,'2019-10-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1822 values(500,'2019-11-30'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1822 values(700,'2018-11-30'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1822;
This will produce the following output −
+--------+------------+ | Amount | DueDate | +--------+------------+ | 1000 | 2019-10-11 | | 500 | 2019-11-30 | | 700 | 2018-11-30 | +--------+------------+ 3 rows in set (0.00 sec)
Here is the query to update database record on a specific date −
mysql> update DemoTable1822 set Amount=5000 where DueDate=curdate(); Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1822;
This will produce the following output −
+--------+------------+ | Amount | DueDate | +--------+------------+ | 1000 | 2019-10-11 | | 5000 | 2019-11-30 | | 700 | 2018-11-30 | +--------+------------+ 3 rows in set (0.00 sec)
- Related Articles
- Update MySQL table column by matching date using date() function?
- MySQL select * and find record with current date
- Display all records ignoring the current date record in MySQL
- MySQL query to insert current date plus specific time?
- Display record with today and tomorrow’s date from a column with date record in MySQL
- How to select a specific record from MySQL if date is in VARCHAR format?
- How to filter dates in MySQL to fetch date record only for a specific month?
- MySQL date column auto fill with 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
- Set a specific Date Format in MySQL?
- MySQL DATE function to return the difference between current date and joining date
- How to select a date less than the current date with MySQL?
- Find date record after a particular date from a column with VARCHAR type in MySQL
- Perform MySQL UPDATE on the basis of DATE value in another column

Advertisements