thinkphp去重统计数据sql

DISTINCT 方法用于返回唯一不同的值

官方文档给出的示例:

$Model->distinct(true)->field('userName')->select();  
解析的SQL:SELECT DISTINCT `userName` FROM `table`

去重统计:

$totalRows = $this->where($where)->count('DISTINCT mobilePhone')
解析的SQL:SELECT COUNT(DISTINCT mobilePhone) AS tp_count FROM `table` WHERE `check` = 1

原文作者:rinald
原文地址:http://fity.cn/post/512.html
请您在转载时保留此出处信息,尊重别人也是尊重自己。

原文地址:https://www.cnblogs.com/blibli/p/7944578.html