select "type"+type as type,count(*) as num from table1 group by type

解决方案 »

  1.   

    楼上大哥,能讲讲上面这句sql的意思吗?
      

  2.   

    count()函数:统计字段中符合条件数据数量的合计~~~
      

  3.   

    SELECT type,count(Type) FROM table GROUP BY type这样写能看懂吗~~~
      

  4.   

    SELECT type,count(Type) FROM table GROUP BY type
    什么读取啊?用php
      

  5.   

    while($all_num = $db->mysql_fetch_array($db->mysql_query("SELECT type,COUNT(type) FROM posts GROUP BY type")))
    {
            echo$all_num;
    }
    不行啊
      

  6.   

    select count(*) from tablename group by type
      

  7.   

    while($all_num = $db->mysql_num_rows($db->mysql_query("SELECT type,COUNT(type) FROM posts GROUP BY type")))
    {
            echo$all_num;
    }
      

  8.   

    $sql="SELECT type,count(Type) as nums FROM table GROUP BY type";
    $result=mysql_query("$sql")
    while($arr=mysql_fetch_array($result))
    {
    echo $arr["type"];
    echo $arr["nums"];
    }
    这样你应该理解吧..