2013-07-23 190 views
0

这是一个非常基本的问题,非常抱歉。为什么INSERT INTO语句不工作?

我有一个简单的SQL(MySQL5)表,我试图命令行插入数据到它。但它不断弹出一个错误,我不知道为什么。

这是我的控制台输出:

mysql> SHOW COLUMNS from queries; 

+-------+-----------+------+-----+-------------------+-----------------------------+ 

| Field | Type  | Null | Key | Default   | Extra      | 

+-------+-----------+------+-----+-------------------+-----------------------------+ 

| id | int(11) | NO | PRI | NULL    | auto_increment    | 

| query | varchar(100) | NO |  | NULL    |        | 

| date | timestamp | NO |  | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | 

| match | int(11) | YES |  | NULL    |        | 

+-------+-----------+------+-----+-------------------+-----------------------------+ 

4 rows in set (0.00 sec) 

mysql> INSERT INTO queries (query, match) VALUES ('cheese', 4); 

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match) VALUES ('cheese', 4)' at line 1 

mysql> 

这是怎么回事?为什么我的INSERT INTO命令不起作用?

回答

7

match是一个保留的MySQL字。

试试这个(反引号使用):

INSERT INTO queries (`query`, `match`) VALUES ('cheese', 4);