$result=select * from table
$num=mysql_num_rows($result) 

解决方案 »

  1.   


    知道这样可以,但 select count(*) from table 会快点,但返回的结果不知怎么处理
      

  2.   

    我晕,我写一个,你自己看吧,
    $sql = "select count(*) from tablename";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    echo $row[0]
    这样就可以啦。
      

  3.   


    我写的和你一样 select count(*) as amount fome table
    ...
    ...
    echo $row['amount']但问题不在这里,而是无论你对表增加或删除,读出的记录数都一样,不会改变,怎么回事呢?
      

  4.   

    try
    select count(*) as amount fome table where 1
      

  5.   

    select count(*) as abc from t1
    如果没有as,只能根据字段的顺序来拿数据。
      

  6.   


    where 1 是什么意思呢?
      

  7.   

    select sum('栏位') from table;
    这个也可以实现
      

  8.   

    可能和表的类型有关系,MyISAM类型的表在count的时候如果没有where条件只会返回保存好的行数,不会扫描表的,随便加个where 1 = 1的条件试试看
      

  9.   

    应该是操作错误,这个语句是不会错的,删一个count肯定减一
      

  10.   

    从这个贴子可以看出大部份人的SQL水平是多么的.....哎..
      

  11.   

    数据库有缓存
    删除后 用 FLUSH QUERY CACHE 清缓存
      

  12.   

    缓存吧,你在firfox中试试,ie中默认会缓存,也可能是数据库缓存
      

  13.   

    是不是表名用了关键字啊?select count(*) from `table` 
      

  14.   

    要是这么简单的sql都这么容易出问题...mysql就没什么混头了