子查询的问题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 ");