Home > Database > Mysql Tutorial > How do we update values ​​in MySQL table?

How do we update values ​​in MySQL table?

王林
Release: 2023-09-14 18:33:03
forward
1115 people have browsed it

我们如何更新 MySQL 表中的值?

With the UPDATE statement and WHERE clause, we can update the value of a single row or multiple rows in the table. MySQL updates the value based on the conditions specified in the WHERE clause. For example, suppose in the "employee" table we want to change the "name" and "doj" of the employee with id 1, then this can be done using 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)
Copy after login

The above is the detailed content of How do we update values ​​in MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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