Home > Database > Mysql Tutorial > How to change the value of a row instance in a MySQL table?

How to change the value of a row instance in a MySQL table?

PHPz
Release: 2023-09-04 18:57:10
forward
1155 people have browsed it

如何更改 MySQL 表中行实例的值?

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)
Copy after login

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)
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template