2014-08-31 141 views
0

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

#1136 - 列数并不在第1行中的插入5个值相匹配的值数,但评论ID设置为AUTO INC

插入语句看起来像这样:

insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', '[email protected]', '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)  

任何人都可以 帮帮我?非常感谢您的努力

+1

你缺少值子句中的一个逗号。 – thebjorn 2014-08-31 09:53:19

回答

2

您犯了一个错误。您忘记在所有值之间设置逗号。改变您查询从:

insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', '[email protected]', 'testh' 'unapprove') 

insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', '[email protected]', 'testh', 'unapprove') 
1

你应该 'testh' 后添加逗号,因为它COMMENT_TEXT字段的值。

insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES 
        ('78', 'm man', '[email protected]', 'testh', 'unapprove') 
0

您必须修改您的查询到该

insert INTO comments VALUES (NULL, '78', 'm man', '[email protected]', 'testh', 'unapprove')