TP中统计指定字段的总数
程序员文章站
2022-06-22 10:48:32
如统计已激活设备数量和未激活设备数量 $condition = [ ['member_id', '=', $member_id] ]; $field = [ 'COUNT(IF(active_member_id > 0, 1, null)) as actived_num', 'COUNT(IF(ac ......
如统计已激活设备数量和未激活设备数量
$condition = [ ['member_id', '=', $member_id] ]; $field = [ 'count(if(active_member_id > 0, 1, null)) as actived_num', 'count(if(active_member_id = 0, 1, null)) as unactived_num', ]; $list = $this->where($where)->field($field)->order($order)->select();
上一篇: java基础语法