什么会导致合法的 MySql INSERT INTO 命令失败?
我无法弄清楚是什么导致我的 INSERT INTO 无法插入 MySql 中的某些表。我可以将它们管理到其他表。该表看起来像:
CREATE TABLE IF NOT EXISTS `Match` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`match_no` int(11) NOT NULL,
`season` int(11) NOT NULL,
`hometeam` int(11) NOT NULL,
`awayteam` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `match_no` (`match_no`),
KEY `season` (`season`),
KEY `hometeam` (`hometeam`),
KEY `awayteam` (`awayteam`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
命令
INSERT INTO Match (`match_no`, `season`, `hometeam`, `awaytem`) VALUES (1, 1, 2, 3)
我得到的
是: 1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 'Match (match_no
, season
, hometeam
, 附近使用的正确语法awaytem
) VALUES (1, 1, 2, 3)' at line 1
我已经检查了手册和来自网络的六个示例以及其他什么,并尝试了对语法的各种更改,以防出现一些 MySql 特有的奇怪之处,但似乎没有任何作用。
I can't figure out what's causing my INSERT INTO's to fail to certain table in MySql. I can manage them to other tables. The table looks like:
CREATE TABLE IF NOT EXISTS `Match` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`match_no` int(11) NOT NULL,
`season` int(11) NOT NULL,
`hometeam` int(11) NOT NULL,
`awayteam` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `match_no` (`match_no`),
KEY `season` (`season`),
KEY `hometeam` (`hometeam`),
KEY `awayteam` (`awayteam`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
And the command is
INSERT INTO Match (`match_no`, `season`, `hometeam`, `awaytem`) VALUES (1, 1, 2, 3)
All I get is:
1064 - 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 (match_no
, season
, hometeam
, awaytem
) VALUES (1, 1, 2, 3)' at line 1
I have checked the manual and half-a-dozen examples from the web and whatnought and tried all sorts of changes to the syntax in case there is some MySql specific oddity, but nothing seems to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
awaytem
更改为awayteam
并查看效果如何,并使用“Match”作为表:match
是保留字。Change
awaytem
toawayteam
and see how it goes and use `Match` as the table:match
is a reserved word.Match
是MySQL
中的保留
字。这里是 MySQL 保留字的列表
Enclose Match后面的勾号为:
另外,正如帕克斯指出的那样,您拼错了列名称。
Match
is areserved
word inMySQL
.Here goes the list of MySQL reserved words
Enclose Match in back ticks as:
Also as Pax pointed out you've misspelt a column name.
匹配是一个颠倒的单词
因此,
请注意您用于字段名称的相同反引号
这些不是装饰用的
Match is a reversed word
so,
note the same backticks you used for the fieldnames
these are not for decoration