当前位置:Gxlcms > 数据库问题 > thinkphp去重统计数据sql

thinkphp去重统计数据sql

时间:2021-07-01 10:21:17 帮助过:67人阅读

->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

人气教程排行