1.怎样才能得到select count(id) from table的值?
在jsp下怎么写代吗?数据库是MySql
2.怎样得对多条记录的同一字段(数字)的和?

解决方案 »

  1.   

    问题一:<%
    try{
    ResultSet rst = stmt.excuteQuery("select count(id) from table");
    if(rst.next()){
      rst.getString("count(id)");
    }
    }catch(Exception e){}finally{
      rst.close();
    }
    %>
      

  2.   

    回答二:select sum(字段名) from 表名
      

  3.   

    我也有同样的问题
    jsp中
    要统计某字段的和
    select sum(字段名) from 表名
    但不会显示出来在asp中
    select sum(字段名) from 表名
    显示时rs(0)就可以这种统计函数在jsp中怎样显示?