19.修改表中数据

19.1 修改表中指定条件固定列的数据

1、命令语法:update <表名> set <字段>=<新值>,..... where <条件> (一定要注意条件)

2、修改指定的行字段内容
查看要修改的表

mysql> use oldboy;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from test where id=4; 把 id 号为 4,name=zhangxuan 的更改为 name=pengchun
+----+------+-----------+-------------+
| id | age | name | shouji |
+----+------+-----------+-------------+
| 4 | 24 | zhangxuan | 13511111111 |
+----+------+-----------+-------------+
1 row in set (0.00 sec)
mysql> update test set name='pengchun' where id=4;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from test where id=4;
+----+------+----------+-------------+
| id | age | name | shouji |
+----+------+----------+-------------+
| 4 | 24 | pengchun | 13511111111 |
+----+------+----------+-------------+
1 row in set (0.00 sec)​

猜你喜欢

转载自www.cnblogs.com/hackerlin/p/12539898.html
今日推荐