ThinkPHP子查询

$m = D("qipai_logic.roomhisscoredetail");
$where['uid'] = $uid;    
$productinfo = $m->where($where)->field('roomid,uid,name,max(turn) as roomturn')->group('roomid')->buildSql();//子查询 
$allturn = M()->table($productinfo.' a')->field('uid,name,sum(roomturn) allturn')->select();  //总局数
原文地址:https://www.cnblogs.com/meetuj/p/8435804.html