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
请您在转载时保留此出处信息,尊重别人也是尊重自己。

posted @ 2017-12-01 21:50  郭德纲又打人了嘿  阅读(1894)  评论(0编辑  收藏  举报