
- 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
How to batch update MySQL table?
Let us first create a table −
mysql> create table DemoTable -> ( -> BreakfastTime time -> ); Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('7:30:45'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('8:00:30'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('7:55:00'); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+---------------+ | BreakfastTime | +---------------+ | 07:30:45 | | 08:00:30 | | 07:55:00 | +---------------+ 3 rows in set (0.00 sec)
Following is the query to batch update MySQL table −
mysql> update DemoTable -> set BreakfastTime=addtime(BreakfastTime,'2:00:00'); Query OK, 3 rows affected (0.13 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable;
This will produce the following output−
+---------------+ | BreakfastTime | +---------------+ | 09:30:45 | | 10:00:30 | | 09:55:00 | +---------------+ 3 rows in set (0.00 sec)
- Related Articles
- How to Execute Batch Insert Update in Hibernate?
- How to update MySQL table storage engine
- How to update a timestamp field of a MySQL table?
- Update a MySQL table with Java MySQL
- How to write PHP script to update an existing MySQL table?
- How to update a MySQL table by swapping two column values?
- How to do a batch insert in MySQL?
- How can we update values in a MySQL table?
- Update table with duplicate ids in MySQL
- Update table and order dates in MySQL
- How can we update any value in MySQL view as we can update the values in MySQL table?
- Implement GREATEST() in MySQL and update the table?
- Update MySQL table on INSERT command with triggers?
- How can we update the values in one MySQL table by using the values of another MySQL table?
- Using MySQL in Batch Mode

Advertisements