怎样用变量接收select语句获取的最大值

[复制链接]
查看11 | 回复3 | 2011-6-9 08:32:23 | 显示全部楼层 |阅读模式
String sql2="select max(zong) from t_weisheng where year=? and month=?";
pstat=conn.prepareStatement(sql2);
pstat.setString(1,year);
pstat.setString(2,month);
rs1=pstat.executeQuery();
rs1.getInt("zong");这样获取zong列的值,会说列名无效
怎么获取呢谢谢

回复

使用道具 举报

千问 | 2011-6-9 08:32:23 | 显示全部楼层
String sql2="select max(zong) as maxZong from t_weisheng where year=? and month=?";pstat=conn.prepareStatement(sql2);pstat.setString(1,year);pstat.setString(2,month);rs1=pstat.executeQuery();rs1.getInt("maxZong");...
回复

使用道具 举报

千问 | 2011-6-9 08:32:23 | 显示全部楼层
rs1[0][0]...
回复

使用道具 举报

千问 | 2011-6-9 08:32:23 | 显示全部楼层
while(rs1.next()){
int x=rs1.getInt("zong");}...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行