实现上面sql查询结果的记录总数$sql = select count(C.`cid`) as `c` from (select * from `ctable` group by pid) as C left join `ptable` as P on P.`pid` = C.`pid`;详解,此语句用到了sql子查询,先使用子查询对ctable进行分组查询,然后对分组后的结果集进行统计.