首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

子查询的有关问题select id,(select top 1 username from stu b where a.id=b.id) as usera fr

2012-01-20 
子查询的问题select id,(select top 1 username from stu b where a.idb.id) as usera from stu a group

子查询的问题select id,(select top 1 username from stu b where a.id=b.id) as usera from stu a group by id如何取得其中子查询的值呢
一个数据库查询

select   id,(select   top   1   username   from   stu   b   where   a.id=b.id)   as   usera   from   stu   a   group   by   id

可是在java里用ResultSet   rs  
rs.getObject(2)来取得其中子查询的结果usera,提示报错

在java里该如何得到子查询的结果呢?

[解决办法]
select id,(select top 1 username from stu b where a.id=b.id) as usera from stu a group by id
应该没问题
rs.getObject(2) 是得到整形的数据
rs.getString( "usera ");才是得到数据的字段名
[解决办法]
vrs.getString( "usera ");

热点排行
Bad Request.