JSP怎样才可,获得数据库查询中别名的值

来源:百度知道 编辑:UC知道 时间:2024/06/15 19:51:14
String sql="select count(pid) as rpid from reply where pid="+id;
在JSP中,获取 count(pid)的列, int Pid=rs.getInt("rpid")+1;
运行时会出错。获取不了数据库中别名的值。

这条SQL语句查询出来要么是1,要么是0.
为什么非要用函数呢,
查询任意字段,rs有数据就是1,没有就是0

应该这么写的吧
String sql="select count(pid) as rpid from reply where pid='"+id+"'";