解决 Column count doesn‘t match value count at row 1 的可能思路

今天遇到这个问题:Column count doesn’t match value count at row 1
很明显说的是列不匹配。
示例是 insert into user(colum1,colum2,colum3)
但是values是(字段1,字段2)这种信息。列名不匹配

我这次虽然报这个错误。但是原因是对mybatis的list插入不熟悉导致的。目前我还没想明白原因。但是暂时解决了
正确示例

<insert id="insertBillList" parameterType="com.deng.billsystem.pojo.entity.Bill">
        insert into bill(userid,username,billdate,breakfastfee,lunchfee,dinnerfee,trafficfee,otherfee,otherfeeremark,createtime,updatetime)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.userId},#{item.username},#{item.billDate},#{item.breakfastFee},
            #{item.lunchFee},#{item.dinnerFee},#{item.trafficFee},#{item.otherFee},
            #{item.otherFeeRemark},#{item.createTime},#{item.updateTime}
            )
        </foreach>
    </insert>

错误示例

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用[1]:Column count doesn't match value count at row 1; Column count doesn't match value count at row 1; 原因: 。 引用[2]:Error updating database. Cause: java.sql.SQLException: Column count doesn't match value count at row 1\r\n### The error may involve com.network.dailyplanner.dao.EventDao.addEvent-Inline\r\n### The error occurred while setting parameters\r\n### SQL: insert into biz_event (title, content, start_time, end_time, remind_time, group_id, remark, show_status, event_status, gmt_create) values ( ?, ? ?, ?, ?, ?, ?, ?, ?, now() )\r\n### Cause: java.sql.SQLException: Column count doesn't match value count at row 1\n; bad SQL grammar []; nested exception is java.sql.SQLException: Column count doesn't match value count at row 1 意思是存储的数据与数据库里的数据个数不一致 。 引用[3]:如下:本表有四列,前面没有声明插入列,MySQL默认为全部的列,应插入4个值;但后面插入值的数量不对,故报错。 -- 报错:Column count doesn't match value count at row 1 INSERT INTO `LOL` VALUES (null, 'D刀锋之影', '泰隆'); 解决方法: 。 问题:Column count doesn't match value count at row 1 QueryFailedError: Column count doesn't match value count at row 1 回答: 这个错误通常是由于插入的数据与数据库中的列数不匹配导致的。根据引用[1]和引用[2]的描述,这个错误可能是由于插入的数据个数与数据库中的列数不一致所引起的。例如,在引用[3]中的示例中,插入语句中的值的数量与表中的列数不匹配,导致了这个错误的出现。要解决这个问题,你需要确保插入语句中的值的数量与表中的列数相匹配。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值