用于将特定单元格更新为空的 MySQL 查询
让我们先创建一个表 -
mysql> create table DemoTable ( Id int, Name varchar(50) ); Query OK, 0 rows affected (0.47 sec)
使用 insert 命令向表中插入一些记录 -
mysql> insert into DemoTable values(1001,'Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(1002,'Sam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(1003,'Tom'); Query OK, 1 row affected (0.10 sec)
使用 select 语句显示表中的所有记录 -
mysql> select *from DemoTable;
这将产生以下输出 -
+------+--------+ | Id | Name | +------+--------+ | 1001 | Robert | | 1002 | Sam | | 1003 | Tom | +------+--------+ 3 rows in set (0.00 sec)
以下是对 MySQL 中特定单元格更新为空的查询 -
mysql> update DemoTable set Name='' where Id=1003; Query OK, 1 row affected (0.16 sec) Rows matched: 1 Changed: 1 Warnings: 0
让我们再次查看表记录 -
mysql> select *from DemoTable;
这将产生以下输出 -
+------+--------+ | Id | Name | +------+--------+ | 1001 | Robert | | 1002 | Sam | | 1003 | | +------+--------+ 3 rows in set (0.00 sec)
广告