我用这个语句查询select top 5 * from b1 where id not in(select top 1 id from b1)取出来的记录却是6条,
最后一条为异常
怎么回事啊?请帮帮我!
try{
ResultSet rs=Conn.strSql("select top 5 * from b1 where id not in(select top 1 id from b1)");
while(rs.next()){
for(int i=1;i<=rs.getMetaData().getColumnCount();i++){
System.out.print(rs.getString(i)+"\t");
}
System.out.println();
}
Conn.close();
}catch(SQLException e){
System.out.println("SQL ERROR:"+e.getMessage());
}
最后一条为异常
怎么回事啊?请帮帮我!
try{
ResultSet rs=Conn.strSql("select top 5 * from b1 where id not in(select top 1 id from b1)");
while(rs.next()){
for(int i=1;i<=rs.getMetaData().getColumnCount();i++){
System.out.print(rs.getString(i)+"\t");
}
System.out.println();
}
Conn.close();
}catch(SQLException e){
System.out.println("SQL ERROR:"+e.getMessage());
}
select top 5 * from b1 where id not in(select top 1 id from b1)取出来的记录却是6条,
LZ有没有放在SQL环境下执行过,还是在JAVA里判断,应该是5条
你的异常估计和你的rs.getString(i)中的i值有关
这句i是不是应该从0开始啊
我只有access和vf,在vf下语法错误,我晕
2. System.out.print(rs.getString(i)+"\t");
这句话,你能保证你的表的字段都是字符型?
....}