Describe messages;
Field Type Null Key Default Extra
id int(11) NO PRI NULL auto_increment
title varchar(255) YES NULL
body text YES NULL
to text YES NULL
content_type varchar(255) YES NULL
is_sms tinyint(1) YES NULL
user_id int(11) YES NULL
created_at datetime YES NULL
updated_at datetime YES NULL
然后我尝试插入:
INSERT INTO messages (id,title,body,to) VALUES ('1','Test Message','This is a test message. This is a test message. This is a test message. This is a test message.', 'an email' );
由于某种原因,这会导致一般的MySQL语法错误.如果我删除“to”列并且它是查询中的相应值,则查询工作正常.
有任何想法吗?
解决方法:
‘to’是MySQL中的保留关键字.您需要重命名列.
但是,如果引用保留字,则允许使用保留字作为标识符.
标签:syntax,mysql,text,insert
来源: https://codeday.me/bug/20190713/1445541.html