以下是 UPDATE 命令修改 MySQL 数据表数据的通用 SQL 语法:
UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause]
以下实例将更新数据表中 runoob_id 为 3 的 runoob_title 字段值:
mysql> UPDATE runoob_tbl SET runoob_title='学习 C++' WHERE runoob_id=3; Query OK, 1 rows affected (0.01 sec) mysql> SELECT * from runoob_tbl WHERE runoob_id=3; +-----------+--------------+---------------+-----------------+ | runoob_id | runoob_title | runoob_author | submission_date | +-----------+--------------+---------------+-----------------+ | 3 | 学习 C++ | RUNOOB.COM | 2016-05-06 | +-----------+--------------+---------------+-----------------+ 1 rows in set (0.01 sec)
update users set avatar='files/01/ChMkJlah6X2IFUmnAAvz2hvALAwAAHjswFkjPoAC_Py963.jpg' WHERE uid=1;
参考: