列计数与第1行的值计数不匹配VendorError:1136 [英] Column count doesn't match value count at row 1 VendorError:1136

查看:71
本文介绍了列计数与第1行的值计数不匹配VendorError:1136的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到以下错误:

列数与第1行的值计数不符

我的代码是:

Connection             con=DriverManager.getConnection("jdbc:mysql://127.0.0.1/BFPL","root","ilovepepsi");
PreparedStatement ps=con.prepareStatement("Insert into User values(?,?,?,?,?,?)");
ps.setString(1,t52.getText());
ps.setString(2,pw2.getText());
ps.setString(3,t53.getText());
ps.setString(4,t54.getText());
ps.setInt(5,100);
ps.setInt(6,11);
ps.executeUpdate();
PreparedStatement ps1=con.prepareStatement("Insert into User_Team values(?,?)");
ps1.setString(1,t52.getText());
ps1.setInt(2,0);
ps1.executeUpdate();
con.close();

在第一个表用户中,它们是6列,在第二个表User_team中,它们是13列,我仅在其中插入2个值,第一个值是主键.

in first table user their are 6 columns, and in 2nd table User_team their are 13 columns in which i am inserting just 2 values from which 1st value is primary key.

推荐答案

如果您未在表的所有列中插入,则必须像这样在插入查询中命名要插入的列

If you are not inserting in all columns of a table then you have to name the columns you are inserting into in your insert query like this

Insert into User_Team (col1, col4) values(?,?)

考虑一下-数据库引擎应如何知道这些值属于哪些列?

Think about it - how should the DB engine know which columns the values belong to?

这篇关于列计数与第1行的值计数不匹配VendorError:1136的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆