在字符串输入值上使用单引号。如果有一个标识符,如表名或列名,则不要使用单引号(使用反引号)。
让我们首先创建一个表-create table DemoTable1552
-> (
-> `key` int,
-> Name varchar(20)
-> );
使用插入命令在表中插入一些记录-insert into DemoTable1552 values(101,'Chris');
insert into DemoTable1552 values(102,'David');
insert into DemoTable1552 values(103,'Mike');
使用select语句显示表中的所有记录-select * from DemoTable1552;
这将产生以下输出-+------+-------+
| key | Name |
+------+-------+
| 101 | Chris |
| 102 | David |
| 103 | Mike |
+------+-------+
3 rows in set (0.00 sec)
这是如何使用单引号-update DemoTable1552 set `key`=100 where Name='Chris';
Rows matched: 1 Changed: 1 Warnings: 0
让我们再次检查表记录-select * from DemoTable1552;
这将产生以下输出-+------+-------+
| key | Name |
+------+-------+
| 100 | Chris |
| 102 | David |
| 103 | Mike |
+------+-------+
3 rows in set (0.00 sec)