查询插入日期显示错误?

时间:2011-05-10 10:53:42

标签: php mysql cakephp

我的查询是

INSERT INTO `messages_system(mes_id,mem_id,frm_id,subject,body,messages_system.type,new,folder,date,special,messages_system.read) VALUE('','51','48','title of the message','body of the message','message','new','sent','1305024405','','');`

此查询提供错误

MySQL said: 

#1366 - Incorrect integer value: '' for column 'mes_id' at row 1 

如何解决此问题mes_id是我的主要身份。

3 个答案:

答案 0 :(得分:1)

只需在字段和值列表中省略mes_id

INSERT INTO `messages_system` (mem_id,frm_id,subject,body,messages_system.type,new,folder,date,special,messages_system.read) VALUES ('51','48','title of the message','body of the message','message','new','sent','1305024405','','')

或使用文字NULL初始化它:

INSERT INTO `messages_system` (mes_id, mem_id,frm_id,subject,body,messages_system.type,new,folder,date,special,messages_system.read) VALUES (NULL, '51','48','title of the message','body of the message','message','new','sent','1305024405','','')

答案 1 :(得分:0)

将主键列设置为AUTO_INCREMENT。

答案 2 :(得分:0)

您需要为auto_increment设置mes_id属性,并从查询中删除mes_id