select count(*) from (select uid from oc_commission group by uid) as uid
select count(*) from (select uid from oc_commission group by uid) as uid
你的這個sql可以優化,一句搞定
select count(distinct(uid)) from oc_commission
tp:
M('Commission')->count(distinct(uid));
可以直接用原生程式碼查詢
http://www.kancloud.cn/manual/thinkphp/1775 手冊有子查詢,你好好看看
$sql=M('oc_commission')->field('uid')->group('uid' )->select(false);
$count=M('oc_commission')->table($sql.' a')->count()
如果報錯,去github下載最新版本就不會報錯了