ThinkPHP数据库虚拟表(子查询)
作者:互联网
$subsql = Db::table('think_work') ->where('status',1) ->field('artist_id,count(id) count') ->group('artist_id') ->buildSql(); Db::table('think_user') ->alias('a') ->join([$subsql=> 'w'], 'a.artist_id = w.artist_id') ->select();
表名也可以是一个子查询
标签:count,artist,数据库,Db,虚拟,ThinkPHP,table,subsql,id 来源: https://www.cnblogs.com/momoblog/p/15935628.html