开发者

MySQL Error: ON DUPLICATE KEY UPDATE, column count doesn't match value count at row

Can anyone see why I'm getting this error is causing an error:

#1136 - Column count doesn't match value count at row 1

Here is the query:

INSERT INTO `people` 
(`id`,`title`,`first_name`,`middle_initial`,`preferred_name`,`last_name`,
`home_phone`,`mobile_phone`,`email`,`gender`,`date_of_birth`,`qff`,`status`) 

VALUES ('20','Mr','first','mid','pref','fam',
'home','mobile','email','male','0000-00-00','qff','active') 

ON DUPLICATE KEY UPDATE 
`people`.`id` = LAST_INSERT_ID(`people`.`id`), 
`people`.`title` = 'Mr', 
`people`.`first_name` = 'first', 
`people`.`middle_initial` = 'mid', 
`people`.`preferred_name` = 'pref', 
`people`.`last_name` = 'fam', 
`people`.`home_phone` = 'home', 
`people`.`mobile_phone` = 'mobile', 
`people`.`email` = 'email', 
`people`.`gender` = 'male', 
`people`.`date_of_birth` = '0000-00-00', 
`people`.`qff` = 'qff', 
`people`.`status` = 'active'

And the table structure:

CREATE TABLE `people` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `title` text,
  `first_name` text,
  `middle_initial` text,
  `preferred_name` text,
  `last_name` text,
  `home_phone` text,
  `mobile_phone` text,
  `email` text,
  `gender` enum('male','female') DEFAULT NULL,
  `date_of_birth` date DEFAULT NULL,
  `qff` varchar(20) NOT NULL,
  `status` enum('active','inactive') NOT NULL,
  `updated` timestamp NOT NULL D开发者_如何学运维EFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updated_by` int(10) unsigned DEFAULT NULL,
  `updated_by_type` enum('person','admin') DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;


I had the exact same problem a while ago - for me the issue was related to a trigger on the table in question.


Recently I had the same problem, But I used batch insert/update ,my problem is not about trigger , its the 'foreach' problem, if u used the total 'foreach' like

<foreach collection="meters" index="index" item="meter" open="(" close=")" separator=",">
</foreach>

but the error code is
Error Code: 1136. Column count doesn't match value count at row 1 0.000 sec

for my test it will add another () for your code (I didn't check the log). so we can user

< foreach collection="medichines" index="index" item="medichine" separator=",">

    (
    )

< /foreach>

this way can fix you error

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜