How can we update values in a MySQL table?

MySQLMySQLi Database

With the help of UPDATE statement and WHERE clause, we can update the values in single or multiple rows of the table. MySQL updates the values on the basis of condition specified in WHERE clause. For example, suppose in the ‘employee’ table we want to change the ‘name’ and ‘doj’ of the employee whose id is 1 then it can be done with the following query −

mysql> UPDATE employee SET name = 'Gaurav', doj = '2010-02-01' WHERE id = 1;
Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from employee WHERE id = 1;
+------+--------+------------+
| id   | name   | doj        |
+------+--------+------------+
| 1    | Gaurav | 2010-02-01 |
+------+--------+------------+
1 row in set (0.00 sec)
raja
Published on 19-Feb-2018 16:22:19
Advertisements