写一个插入操作的时候,报错如下:
经过检查发现是inset into语句插入有问题.
我的t_fruit表里有属性 fid, fname, price, fcount ,remark,
fid我设置的是自增长的
知识点:在给表t_fruit中所有的属性进行数值插入的时候,insert into的书写格式为:
insert into t_fruit values(fid,fname,price,fcount,remark);
//只有给所有的属性插值,才能这么写,
所以我正确的插入语句应该是:
insert into t_fruit values(0,?,?,?,?);
而我写的是
insert into t_fruit values(?,?,?,?);//像这种给部分属性插值的正确sql为:
insert into t_fruit (fname,price,fcount,remark) values(?,?,?,?);