请问这个查询如何转为thinkphp形式查询?
程序员文章站
2022-05-11 10:22:40
...
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下载最新版本就不会报错了