SELECT count(*) FROM goods AS g WHERE 1=1 group by catid值得到的是每个cat分类里面的分组的统计数,我想求分组后的总数做分页显示
请问该如何写这个SQL语句

解决方案 »

  1.   

    select count(*) from (SELECT count(*) FROM goods AS g WHERE 1=1 group by catid ) a直接执行
    SELECT count(*) FROM goods AS g WHERE 1=1 group by catid 
    后再执行:
    select found_rows();
      

  2.   

    select found_rows();
    请问这个怎么使用,
      

  3.   

    $sql='SELECT count(*) FROM ecs_goods AS g WHERE 1=1 group by cat_id ';
    $result=$GLOBALS['db']->query($sql);
    请问往下如何执行可以行到总数的值
      

  4.   

    把$sql=
    这样写吧:select count(*) from (SELECT count(*) FROM goods AS g WHERE 1=1 group by catid ) a 
      

  5.   

    SELECT count(*) FROM goods AS g WHERE 1=1 group by catid limit @page,@page+size