my SQL 语句问题

zhoulifang198671 2009-03-06 11:43:31
ResultSet resultset2 = statement.executeQuery("select id from cusinfo where class='"+classname+"' and '"+list.get(i)+"'='"+condition[i]+"'");

numofattib = resultset2.getRow();

从表上看若i=1时numofattib = 2,为什么运行结果是numofattib = 0?
...全文
90 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
岭南笑 2009-03-10
  • 打赏
  • 举报
回复
MS-SQL就学过!

My-SQL学习中!
KAKUKYOWU 2009-03-10
  • 打赏
  • 举报
回复
貌似多了些没用的'符号~~
angel_bear 2009-03-09
  • 打赏
  • 举报
回复
如果list.get(i)是想作为字段名拼接的话就如楼上所说将“‘”去到。
youzi530 2009-03-09
  • 打赏
  • 举报
回复

ResultSet resultset2 = statement.executeQuery("select id from cusinfo where class='"+classname+"' and '"+list.get(i)+"'='"+condition[i]+"'");

这里and '"+ 和 +"'='
多了个'吧
ResultSet resultset2 = statement.executeQuery("select id from cusinfo where class='"+classname+"' and "+list.get(i)+"='"+condition[i]+"'");
这样
youzi530 2009-03-09
  • 打赏
  • 举报
回复

ResultSet resultset2 = statement.executeQuery("select id from cusinfo where class='"+classname+"' and '"+list.get(i)+"'='"+condition[i]+"'");

这里and '"+
多了个'吧
ResultSet resultset2 = statement.executeQuery("select id from cusinfo where class='"+classname+"' and "+list.get(i)+"'='"+condition[i]+"'");
这样
youzi530 2009-03-09
  • 打赏
  • 举报
回复
ResultSet resultset2 = statement.executeQuery("select id from cusinfo where class='"+classname+"' and '"+list.get(i)+"'='"+condition[i]+"'");

这里and '"+
多了个'吧
ResultSet resultset2 = statement.executeQuery("select id from cusinfo where class='"+classname+"' and "+list.get(i)+"'='"+condition[i]+"'");
这样
createWang 2009-03-06
  • 打赏
  • 举报
回复
("select id from cusinfo where class='"+classname+"' and '"+list.get(i)+"'='"+condition[i]+"'");

拼接

62,614

社区成员

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

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