Select*fromtesting;+----+------- --+|Id|Name |+----+---------+|1 |Harshit||2 |Lovkesh||3 |R"/> Select*fromtesting;+----+------- --+|Id|Name |+----+---------+|1 |Harshit||2 |Lovkesh||3 |R">
The UPDATE command along with the WHERE clause can be used to change the value of a row instance. Basically, MySQL changes the value based on the conditions given in the query. The following example can demonstrate it
Suppose we want to change the name from "Ram" to "Mohit" in the "testing" table given below -
mysql> Select * from testing; +----+---------+ | Id | Name | +----+---------+ | 1 | Harshit | | 2 | Lovkesh | | 3 | Ram | | 4 | Gaurav | +----+---------+ 4 rows in set (0.00 sec)
Now, by running the following query , we can change the instance of row to "Mohit" where it is "ram".
mysql> UPDATE TESTING SET Name = 'MOHIT' WHERE name = ‘ram’; Query OK, 1 row affected (0.13 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> Select * from testing; +-----+---------+ | id1 | Name | +-----+---------+ | 1 | Harshit | | 2 | Lovkesh | | 3 | MOHIT | | 4 | Gaurav | +-----+---------+ 4 rows in set (0.00 sec)
The above is the detailed content of How to change the value of a row instance in a MySQL table?. For more information, please follow other related articles on the PHP Chinese website!