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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度