更新 UPDATE
更新表中特定行
mysql> update customers2 set cust_email = 'abc@example.com' where cust_id = '10006';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from customers2;
+---------+----------------+---------------------+-----------+------------+----------+--------------+--------------+---------------------+
| cust_id | cust_name | cust_address | cust_city | cust_state | cust_zip | cust_country | cust_contact | cust_email |
+---------+----------------+---------------------+-----------+------------+----------+--------------+--------------+---------------------+
| 10001 | Coyote Inc. | 200 Maple Lane | Detroit | MI | 44444 | USA | Y Lee | ylee@coyote.com |
| 10002 | Mouse House | 333 Fromage Lane | Columbus | OH | 43333 | USA | Jerry Mouse | NULL |
| 10003 | Wascals | 1 Sunny Place | Muncie | IN | 42222 | USA | Jim Jones | rabbit@wascally.com |
| 10004 | Yosemite Place | 829 Riverside Drive | Phoenix | AZ | 88888 | USA | Y Sam | sam@yosemite.com |
| 10005 | E Fudd | 4545 53rd Street | Chicago | IL | 54545 | USA | E Fudd | NULL |
| 10006 | abc | 453 Main street | los | ca | 99045 | usa | NULL | abc@example.com |
| 10007 | abc | 453 Main street | NULL | NULL | 99045 | NULL | NULL | NULL |
+---------+----------------+---------------------+-----------+------------+----------+--------------+--------------+---------------------+
7 rows in set (0.11 sec)
mysql> update customers2 set cust_contact = 'avc',cust_email = 'abc@example.com' where cust_id = '10006';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
更新表中所有行
删除delete
***先写update delete 再写where 最后写from
mysql> delete from customers2 where cust_id = '10004';
357



被折叠的 条评论
为什么被折叠?



