doujiang2641 2014-08-19 07:55
浏览 39
已采纳

mysql行由where子句计数

look at the database here ---->http://www.tiikoni.com/tis/view/?id=908d940

in the subcommentid rows, value 63 is repeating maximum time itself 7 times

i want to fetch this value in numerical form means like this

maximum rows in subcommentid is 7

i hv tried this

$query=mysqli_query("SELECT * FROM table WHERE where id='63'");
    echo mysqli_num_rows($query);

but

but 63 is a variable so how can a server pre decide that 63 is repeating itself maximum nos

nd look at dix ques too cant get my desire result of max(like)

  • 写回答

4条回答 默认 最新

  • duanjipiao7076 2014-08-19 08:33
    关注

    Try using this query -

    $query = mysqli_query("SELECT subcommentid,COUNT(*) as count FROM table GROUP BY subcommentid ORDER BY count DESC;");
    $result = mysqli_fetch_array($query);
    echo $result['subcommentid'].'<br/>'; //subcomment id
    echo $result['count']; // number of rows
    

    If you want all, store in array -

    $results = array();
    while($row = mysqli_fetch_array($query)) {
        $results[$row['subcommentid']] = $row['count'];
    }
    echo "<pre>";print_r($results);exit;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考