SELECT tb_inport.id,tb_inport.goodsid,tb_goods.goodsname,tb_goods.price,tb_inport.number,tb_inport.price,tb_inport.providerid,tb_provider.providername,tb_inport.inporttime,tb_inport.operateperson  FROM tb_inport,tb_goods,tb_provider  where tb_goods.id=tb_inport.goodsid and tb_provider.id=tb_inport.providerid
这个查询,要求出记录总数,用来分页请问怎么求?

解决方案 »

  1.   

    如果你这查询出来的是个LIST,那么总数就是LIST.SIZE()嘛。
      

  2.   

    select count(1)from tb_inport,tb_goods,tb_provider   where tb_goods.id=tb_inport.goodsid and tb_provider.id=tb_inport.providerid
      

  3.   

    为什么是count(1) 不是count(*)呢 
      

  4.   

    结果都是一样的。如果用list.size(),效率会低很多。
      

  5.   

    解析sql语句生成select count(*) from ... 或把原sql包成一个子查询再
    select count(*) from 
    (....原sql...) abc查出记录数
      

  6.   

    select count(*) from(SELECT tb_inport.id,tb_inport.goodsid,tb_goods.goodsname,tb_goods.price,tb_inport.number,tb_inport.price,tb_inport.providerid,tb_provider.providername,tb_inport.inporttime,tb_inport.operateperson   FROM tb_inport,tb_goods,tb_provider   
    where tb_goods.id=tb_inport.goodsid and tb_provider.id=tb_inport.providerid)as b)
      

  7.   

    一样的,求得的总的记录数count(*)不就是求得的第一个字段的记录数count(1)吗