JOIN 新表 临时表 联表查询

 另一张表聚合后的数据,取出Id,过滤条件  JOIN 新表 临时表

SELECT u.id, u.`BizName` ,u.`Phone` ,from_unixtime(t.`CreateTs`) AS CreateTime ,tr.Num FROM `team` t LEFT JOIN `player` u on t.`LeaderId` = u.`id` LEFT JOIN

(SELECT COUNT(1) AS Num, TeamId FROM team_role_used WHERE `BizStatus` !=3 GROUP BY `TeamId` ) AS tr ON t.`Id` = tr.TeamId WHERE tr.Num>16

ORDER BY t.CreateTs desc

 

posted @ 2021-04-26 18:53  papering  阅读(361)  评论(0编辑  收藏  举报