让我们首先创建一个表-
mysql> create table DemoTable2029 -> ( -> Id int, -> FirstName varchar(20), -> LastName varchar(20) -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable2029 values(1,'Chris','Brown') -> ; mysql> insert into DemoTable2029 values(2,'David','Miller'); mysql> insert into DemoTable2029 values(3,'John','Smith'); mysql> insert into DemoTable2029 values(4,'John','Brown');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable2029;
这将产生以下输出-
+------+-----------+----------+ | Id | FirstName | LastName | +------+-----------+----------+ | 1 | Chris | Brown | | 2 | David | Miller | | 3 | John | Smith | | 4 | John | Brown | +------+-----------+----------+ 4 rows in set (0.00 sec)
以下是更新特定单元格的查询-
mysql> update DemoTable2029 -> set FirstName='Adam',LastName='Smith' -> where Id=4; Rows matched: 1 Changed: 1 Warnings: 0
让我们再次检查表记录-
mysql> select *from DemoTable2029;
这将产生以下输出-
+------+-----------+----------+ | Id | FirstName | LastName | +------+-----------+----------+ | 1 | Chris | Brown | | 2 | David | Miller | | 3 | John | Smith | | 4 | Adam | Smith | +------+-----------+----------+ 4 rows in set (0.00 sec)