Obvious MySQL error?
I'm getting the following error and no matter how I gazillion-check it, even with others, I can't find the mistake:
Query:
INSERT INTO keymaps ( CharacterID, Key, Type, Action ) VALUES ( '100002', '18', '4', '0' )
Error:
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
The table is called keymaps
, and it contains:
int(11) ID
(auto increment)int(11) CharacterID
int(11) Key
smallint(6) Type
开发者_如何学Gosmallint(6) Action
None of the fields allow null.
What's the matter?
Note: I didn't know whether to post this on SF or SO, but I thought it would be more appropriate on SO as it is language syntax. Feel free to move it.
Key
is a reserved word. You need to wrap it in backticks.
INSERT INTO keymaps ( `CharacterID`, `Key`, `Type`, `Action` )
mySQL reserved words
精彩评论