ThinkPHP distinct count 统计查询写法
下面示例是使用 ThinkPHP 6 查询数据表某个字符不重复记录的总个数:
use think\facade\Db;
...
$count_res = Db::connect('zs')->table('member_luck_log')
->where('set_id', $set_id)
->where('set_item_id', $item_id)
->field(Db::raw('COUNT(distinct(`vipcode`)) as `count_sum`'))
->find();
echo $count_res['count_sum'];
本文来自博客园,作者:imzhi,转载请注明原文链接:https://www.cnblogs.com/imzhi/p/15851429.html