明显的MySQL错误?

Laz*_*zlo 1 mysql

我收到了以下错误,无论我如何检查它,即使与其他人一起,我也找不到错误:

查询:

INSERT INTO keymaps ( CharacterID, Key, Type, Action ) VALUES ( '100002', '18', '4', '0' )
Run Code Online (Sandbox Code Playgroud)

错误:

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 'Key, Type, Action ) VALUES ( '100002', '18', '4', '0' )' at line 1
Run Code Online (Sandbox Code Playgroud)

该表被调用keymaps,它包含:

  • int(11) ID (自动递增)
  • int(11) CharacterID
  • int(11) Key
  • smallint(6) Type
  • smallint(6) Action

没有字段允许null.

怎么了?

注意:我不知道是在SF还是SO上发布这个,但我认为它更适合SO,因为它是语言语法.随意移动它.

Pek*_*ica 7

Key是一个保留字.你需要用反引号包装它.

INSERT INTO keymaps ( `CharacterID`, `Key`, `Type`, `Action` ) 
Run Code Online (Sandbox Code Playgroud)

mySQL保留字