2014-08-31 142 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')