

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
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 Questions & Answers
- 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?
- MySQL date column auto fill with current date?
- 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?
- Comparison of varchar date records from the current date in MySQL
- Select dates between current date and 3 months from the current date in MySQL?
- MySQL - Insert current date/time?
- Set a specific Date Format in MySQL?
- 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?
- Find the difference between current date and the date records from a MySQL table
- Check if the current date falls in a given date range using MySQL query
Advertisements