码迷,mamicode.com
首页 > 数据库 > 详细

thinkphp去重统计数据sql

时间:2017-12-01 23:26:36      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:nal   html   rom   span   targe   post   color   field   ble   

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

thinkphp去重统计数据sql

标签:nal   html   rom   span   targe   post   color   field   ble   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!