Let us first create a table −
mysql> create table DemoTable1903 ( FirstName varchar(20), LastName varchar(20) , Age int ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1903 values('John','Smith',23); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1903 values('None','Miller',28); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1903 values('None','Taylor',26); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1903 values('Chris','Brown',26); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1903;
This will produce the following output −
+-----------+----------+------+ | FirstName | LastName | Age | +-----------+----------+------+ | John | Smith | 23 | | None | Miller | 28 | | None | Taylor | 26 | | Chris | Brown | 26 | +-----------+----------+------+ 4 rows in set (0.00 sec)
Here is the query to update column names and set NONE with N/A −
mysql> update DemoTable1903 set FirstName='N/A' where FirstName='None'; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1903;
This will produce the following output −
+-----------+----------+------+ | FirstName | LastName | Age | +-----------+----------+------+ | John | Smith | 23 | | N/A | Miller | 28 | | N/A | Taylor | 26 | | Chris | Brown | 26 | +-----------+----------+------+ 4 rows in set (0.00 sec)