开发者

Mysql super strange syntax error?

INSERT INTO pmessage (content, time, sent_by, to) VALUES ('k', '0000-00-00 00:00:00', 84, 1);

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 'to) VALUES('tt', '2011-04-28 14:04:45', 84, 1)' at line 1

The problem is i cannot see anything wrong with my syntax. There is nothing wrong with the column names etc, we tried many times. We copy/pasted the exact insert command from internet a few times than edited and still we got same error.

Anyone have开发者_Go百科 any idea? The server is a MySQL 5 server


TO is a reserved word. See here: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html.

Try this instead:

INSERT INTO pmessage (content, time, sent_by, `to`)
VALUES ('k', '0000-00-00 00:00:00', 84, 1);


to is a MySQL keyword. You cannot just use it free like that. Try [to]


You problem is that to is a MySQL reserved word, so you'll need to quote it.


to is a reserver word: http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html


Wrap "to" in backticks

INSERT INTO pmessage (content, time, sent_by, `to`) VALUES ('k', '0000-00-00 00:00:00', 84, 1);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜