mysql Column count doesn't match value count at row 1
今天执行批量插入的操作,发现报了错 mysql Column count doesn't match value count at row 1。
后来发现原因:是由于写的SQL语句里列的数目和后面的值的数目不一致, 比如insert into 表名 (field1,field2,field3) values('a','b')这样前面的是三列,后面却只有二个值,这就会出现这个错误的。

查看mapper写法
<insert id="insertBatch" useGeneratedKeys="true" parameterType="java.util.List">
INSERT INTO sys_basic_info(
<include refid="dbColumns" />
) VALUES
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
#{item.groupId},
#{item.groupName},
#{item.groupCode}
</foreach>
</insert>
原因很容易发现,foreach标签属性open和close配置有误!这样大括号会把整体包起来,正确应为:
<insert id="insertBatch" useGeneratedKeys="true" parameterType="java.util.List">
INSERT INTO sys_basic_info(
<include refid="dbColumns" />
) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.groupId},
#{item.groupName},
#{item.groupCode}
)
</foreach>
</insert>
mysql Column count doesn't match value count at row 1的更多相关文章
- mysql提示Column count doesn't match value count at row 1错误
mysql提示Column count doesn't match value count at row 1错误,后来发现是由于写的SQL语句里列的数目和后面的值的数目不一致, 比如insert in ...
- mysql错误:Column count doesn't match value count at row 1
mysql错误:Column count doesn't match value count at row 1 mysql错误:Column count doesn't match value cou ...
- 开发中运行mysql脚本,发现提示mysql提示Column count doesn't match value count at row 1错误
开发中运行mysql脚本,发现提示mysql提示Column count doesn't match value count at row 1错误, 调试后发现是由于写的SQL语句里列的数目和后面的值 ...
- sql语句出错:Column count doesn't match value count at row 1
报错内容: java.sql.SQLException: Column count doesn't match value count at row 1 at com.mysql.jdbc.SQLEr ...
- 报错:Column count doesn't match value count at row 1
mysql错误:Column count doesn't match value count at row 1 意思是存储的数据与数据库表的字段类型定义不相匹配. 解决办法:检查段类型是否正确, 是否 ...
- [Mybatis - 1A] - Cause: java.sql.SQLException: Column count doesn't match value count at row 1
严重: Servlet.service() for servlet [springMVC] in context with path [/ExceptionManageSystem] threw ex ...
- [Err] 1136 - Column count doesn't match value count at row 1
1 错误描述 [Err] 1136 - Column count doesn't match value count at row 1 Procedure execution failed 1136 ...
- java.sql.SQLException:Column count doesn't match value count at row 1
1.错误描述 java.sql.SQLException:Column count doesn't match value count at row 1 2.错误原因 在插入数据时,插入的字段 ...
- java.sql.SQLException: Column count doesn't match value count at row 1 Query: insert into category values(null,?,?,?) Parameters: [1111111, 1111, 软件]
java.sql.SQLException 问题: java.sql.SQLException: Column count doesn't match value count at row 1 Que ...
随机推荐
- PLSQL的SQL%NOTFOUND的使用场景
SELECT * INTO v_ticketStorageRow FROM BDM_TICKET_STORAGE WHERE p_startTicketNo >= START_NO_ AND p ...
- SQL 、NoSQL数据库教程
前言: 嗯,先说说数据库的分类吧,其实主要大的分类就是关系型数据库(SQL)和非关系型数据库(NoSQL); 实验楼上有常见的数据库教程,这里做一个整理,希望对你学习数据库方面的知识有所帮助: 关系型 ...
- [LeetCode] 581. Shortest Unsorted Continuous Subarray_Easy tag: Sort, Stack
Given an integer array, you need to find one continuous subarray that if you only sort this subarray ...
- [LeetCode] 596. Classes More Than 5 Students_Easy tag:SQL
There is a table courses with columns: student and class Please list out all classes which have more ...
- 石子合并(区间DP经典例题)
题目链接:https://www.luogu.org/problemnew/show/P1880 #include <cstdio> #include <cmath> #inc ...
- MySQL数据类型--与MySQL零距离接触2-11MySQL自动编号
MySQL自动编号,确保数据的唯一性
- iOS 第三方框架-MJExtension
1.数组转换成模型数组 // 将 "微博字典"数组 转为 "微博模型"数组 NSArray *newStatuses = [HWStatus objectArr ...
- EF There is already an open DataReader associated with this Command
捕捉到 System.InvalidOperationException _HResult=-2146233079 _message=意外的连接状态.在使用包装提供程序时,请确保在已包装的 DbCon ...
- 数据库所有者 (dbo)
数据库所有者 (dbo) dbo 是具有在数据库中执行所有活动的暗示性权限的用户.将固定服务器角色 sysadmin 的任何成员都映射到每个数据库内称为 dbo 的一个特殊用户上.另外,由固定服务器角 ...
- XMLHttpRequest对象(Ajax)的状态码(readystate) HTTP状态代码(status)
2018-11-28 14:19:00 来自 :XMLHttpRequest对象(Ajax)的状态码(readystate) HTTP状态代码(status) XMLHttpRequest对象(Aj ...