![](/img/trans.png)
[英]Use current auto_increment value as basis for another field in the same INSERT query - is this possible in MySQL?
[英]Insert query in mysql with an auto_increment field
好,
我确定我在这里做错了什么,但我无法终生解决。
这是我的桌子
CREATE TABLE `email_queue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`from` varchar(256) DEFAULT NULL,
`to` varchar(4182) DEFAULT NULL,
`cc` varchar(4182) DEFAULT NULL,
`subject` varchar(4182) DEFAULT NULL,
`body` varchar(4182) DEFAULT NULL,
`status` varchar(64) DEFAULT NULL,
`attempts` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`)
)
当我做一个
insert into email_queue values (1,'','','','','','',0);
它工作正常并插入空白值
但是当我尝试使用
insert into email_queue(to) values('sample_to_name');
它错误地指出ERROR 1064(42000):您的SQL语法有错误; 检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的'to)v alues('sample_to_name')'附近使用
我究竟做错了什么?
您需要回拨
insert into email_queue(`to`) values('sample_to_name');
问题是因为
to is mysql reserved word
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.