Let us first create a table −
mysql> create table DemoTable2029 -> ( -> Id int, -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.98 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2029 values(1,'Chris','Brown') -> ; Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable2029 values(2,'David','Miller'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable2029 values(3,'John','Smith'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable2029 values(4,'John','Brown'); Query OK, 1 row affected (0.27 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable2029;
This will produce the following output −
+------+-----------+----------+ | Id | FirstName | LastName | +------+-----------+----------+ | 1 | Chris | Brown | | 2 | David | Miller | | 3 | John | Smith | | 4 | John | Brown | +------+-----------+----------+ 4 rows in set (0.00 sec)
Following is the query to update a specific cell −
mysql> update DemoTable2029 -> set FirstName='Adam',LastName='Smith' -> where Id=4; Query OK, 1 row affected (0.14 sec) Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable2029;
This will produce the following output −
+------+-----------+----------+ | Id | FirstName | LastName | +------+-----------+----------+ | 1 | Chris | Brown | | 2 | David | Miller | | 3 | John | Smith | | 4 | Adam | Smith | +------+-----------+----------+ 4 rows in set (0.00 sec)