sql语句问题,各位大侠帮忙看一下,急死我了!!!!!!!!

zengzz 2010-05-08 11:23:15
sql="update student_score set qimo_score='"+qimo_score+"',total_score='"+total_score+"' where s_number='"+s_number+"'";帮忙我看一下啊这段代码有什么错误啊?qimo_score和total_score都是float型
...全文
182 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinghua_zhou 2010-05-10
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 lijinglong6140 的回复:]

sql="update student_score set qimo_score='"+qimo_score+"' and total_score='"+total_score+"' where s_number='"+s_number+"'";
跟加引号没有关系!
这样你试试,如果他返回0,没有报错的话证明没找到适合的条件,无法修改!
[/Quote]


ding
tfish2014 2010-05-09
  • 打赏
  • 举报
回复
帮顶!!!
情傷 2010-05-08
  • 打赏
  • 举报
回复
String sql = "update student_score set qimo_score="+qimo_score+",total_score="+total_score+" where s_number=s_number"
如果是用预处理器(PreparedStatement)做查询,建议String sql = "update student_score set qimo_score = ?,total_score = ? where s_number = s_number"
PreparedStatement.setFolat(1,参数名);
PreparedStatement.setFolat(2,参数名);
豆大仁 2010-05-08
  • 打赏
  • 举报
回复
看不出问题,有问题感觉可能也是float类型的事吧,没这么用过。
自己把语句仍到sql分析器里执行下试试,看看有错误没。
或者直接把float类型转换成字符串。
qustgjk 2010-05-08
  • 打赏
  • 举报
回复
当然有错误了, 既然qimo_score和total_score都是float型, 那sql中就不用加单引号
sql=" update student_score set qimo_score= "+qimo_score+", total_score="+total_score+" where s_number='"+s_number+"' ";
laker_914 2010-05-08
  • 打赏
  • 举报
回复
s_number 你的这个也应该是个float型吧
whlcy 2010-05-08
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 lijinglong6140 的回复:]
sql="update student_score set qimo_score='"+qimo_score+"' and total_score='"+total_score+"' where s_number='"+s_number+"'";
跟加引号没有关系!
这样你试试,如果他返回0,没有报错的话证明没找到适合的条件,无法修改!
[/Quote]

up!!!!!
bober 2010-05-08
  • 打赏
  • 举报
回复
float等所有数字类型都不能加单引号的
lalapool 2010-05-08
  • 打赏
  • 举报
回复
如果是sql语句错了的话
会报错的吧。
建议用3楼的形式。。。
jiajerry0 2010-05-08
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhengwei804 的回复:]

String sql = "update student_score set qimo_score="+qimo_score+",total_score="+total_score+" where s_number=s_number"
如果是用预处理器(PreparedStatement)做查询,建议String sql = "update student_score set qimo_sc……
[/Quote]
这样就好多了吧
zhoujiangzi 2010-05-08
  • 打赏
  • 举报
回复
你的那个引号弄错了。。。。
qustgjk 2010-05-08
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 zengzhaohi 的回复:]
一楼的大哥,我像那样做也没有反应,不报错,只是更新的语句是0,还是不行
[/Quote]
s_number是什么类型?
你打出sql来,然后在DB中执行,看看效果。 你上面说是更新的语句是0,而且没有报错,说明你的update影响到的行数为0,你更新的条件是不是没有符合的啊?
lijinglong6140 2010-05-08
  • 打赏
  • 举报
回复
sql="update student_score set qimo_score='"+qimo_score+"' and total_score='"+total_score+"' where s_number='"+s_number+"'";
跟加引号没有关系!
这样你试试,如果他返回0,没有报错的话证明没找到适合的条件,无法修改!
huaye 2010-05-08
  • 打赏
  • 举报
回复
三个参数都是整型,你却全部加了引号,
zfq642773391 2010-05-08
  • 打赏
  • 举报
回复
s_number是什么类型?字符还是整数?
zengzz 2010-05-08
  • 打赏
  • 举报
回复
一楼的大哥,我像那样做也没有反应,不报错,只是更新的语句是0,还是不行

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧