1
INSERT INTO mo_received 
(appid, msg, to, from, operator, keyword, smsid, udh, response, created) 
VALUES 
('13846', 'HELLO', '123456789', '987654321', 
'SKTELECOM', 'Cheese', 'MESSAGE', 'UDHSTUFF', '', NOW());

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取正确的语法,以便在 'to、from、operator、keyword、smsid、udh、response、created)附近使用 VALUES(第 1 行的'13846'、'HE'

这就是我得到的错误。

奇怪的是,如果我删除“to”和“from”字段和值,插入工作正常。但我认为这些领域没有任何问题。

有任何想法吗?

4

2 回答 2

2

列名不推荐使用“to”和“from”。它是保留的。
http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

如果您使用保留的列名,请用反向单引号括起来。

INSERT INTO mo_received (appid, msg, `to`, `from`, operator, keyword, smsid, udh, response, created) 
于 2012-04-25T02:27:23.637 回答
1

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

于 2012-04-25T02:27:34.497 回答