开发框架 版主:迅睿框架研发组
sql分组查询统计数据的问题
类型:迅睿CMS 更新时间:2022-07-13 15:50:55 分组查询

我想从1_zhgl这个数据表中,按照startnum这个字段分组,统计出各分组下的gold等物资的数量。这个代码好像写的哪里不对。

                                        <?php $query=urlencode('select startnum , count('gold') as c  from @#1_zhgl group by startnum');?>
                                        {sql sql='$query' page=1 pagesize=10 urlrule=index.php?page=[page]}
                                        {$t.startnum}-{$t.c}<br>
                                        {/sql}
                                        {$pages}
                                        {$debug}

回帖
  • 薄荷绿
    #1楼    薄荷绿
    2022-07-13 12:00:53
    Chrome 0
    php技术不合格
    <?php $query=urlencode('select startnum , count(\'gold\') as c  from @#1_zhgl group by startnum');?>
  • 仿站织梦转换特199
    #2楼    仿站织梦转换特199
    2022-07-13 12:22:11
    Chrome 0
    薄荷绿 不对 还是报错
  • 仿站织梦转换特199
    #3楼    仿站织梦转换特199
    2022-07-13 12:25:08
    Chrome 0
    44                                         <?php $query=urlencode('select startnum , count(\'gold\') as c  from @#1_zhgl group by startnum');?>

    DivisionByZeroError

  • 小黄人 18html
    #4楼    小黄人 18html
    2022-07-13 12:39:29
    安卓手机 0
    count('gold')这是一个错,其它睡醒再看
  • 小黄人 18html
    #5楼    小黄人 18html
    2022-07-13 12:39:40
    安卓手机 0
    不需要斜杆
  • 仿站织梦转换特199
    #6楼    仿站织梦转换特199
    2022-07-13 13:21:25
    Chrome 0
     <?php $query=urlencode('select startnum from dr_1_zhgl group by startnum;');?>
  • 仿站织梦转换特199
    #7楼    仿站织梦转换特199
    2022-07-13 13:21:37
    Chrome 0
    这样就可以了
    满意答案
  • 仿站织梦转换特199
    #8楼    仿站织梦转换特199
    2022-07-13 15:50:55
    Chrome 0
    @仿站织梦转换特199:参考上边的 改为dr_