改写你的sql语句,把相同条件的count(*)选出来。

解决方案 »

  1.   

    试一下:
    ResultSet rs=conn.executeQuery("select count(*) from tablename where" + 条件判断);
    rs.next();
    int totalrow=rs.getInt(1);不知道效率会不会高一点
      

  2.   

    感觉JAVA在这个上面做的不是很好啊
      

  3.   

    俺通常都用
    select count(*) from tablename
      

  4.   

    select count(*) as count from tablename
      

  5.   

    谢谢各位,不知各位有没有比较过,在数据量不是很大的情况下,使用select count(*) as count from tablename
    和 resultSet.getRow();哪个方法效率高一点?
      

  6.   

    在数据库里的统计比在代码里的统计效率要高得多,所以
    select count(*) from tablename的效率要比resultSet.getRow()高