繁体   English   中英

MYsql插入语句错误

[英]MYsql insert statement error

运行插入语句时出现mysql错误。 错误是:

#1136-列数与第1行的值数不匹配。插入内容有5个值,但注释ID设置为AUTO INC

插入语句如下所示:

insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', 'mon@mon.com', 'testh' 'unapprove')

桌子看起来像这样

1) comment_id       int(10)     AUTO_INCREMENT  
2) post_id          int(10)                 
3) comment_name     varchar(100)
4) comment_email    varchar(100)  
5) comment_text     (text)  
6) status           (text)

有人可以帮忙吗? 非常感谢您的努力

你错了。 您忘记在所有值之间设置逗号。 将查询从以下位置更改:

insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', 'mon@mon.com', 'testh' 'unapprove')

insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', 'mon@mon.com', 'testh', 'unapprove')

您应该在'testh'之后添加逗号,因为它是comment_text字段的值。

insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES 
                     ('78', 'm man', 'mon@mon.com', 'testh', 'unapprove')

您必须将查询修改为此

insert INTO comments VALUES (NULL, '78', 'm man', 'mon@mon.com', 'testh',  'unapprove')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM