Let us first create a table −
mysql> create table DemoTable ( Id int, Name varchar(50) ); Query OK, 0 rows affected (0.47 sec)
Insert some records in the table using insert command −
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)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+--------+ | Id | Name | +------+--------+ | 1001 | Robert | | 1002 | Sam | | 1003 | Tom | +------+--------+ 3 rows in set (0.00 sec)
Following is the query to update a specific cell to be empty in MySQL −
mysql> update DemoTable set Name='' where Id=1003; Query OK, 1 row affected (0.16 sec) Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+------+--------+ | Id | Name | +------+--------+ | 1001 | Robert | | 1002 | Sam | | 1003 | | +------+--------+ 3 rows in set (0.00 sec)