56,677
社区成员
发帖
与我相关
我的任务
分享
select uid,
(select count(*) from orders where uid=users.uid),
(select count(*) from products where uid=users.uid)
from users
select T1.uid, ifnull(T2.uid, 0), ifnull(T3.uid, 0)
from users as T1
left join (select count(uid) as uid from orders group by uid) as T2
on T1.uid =T2.uid
left join ((select count(uid) as uid from products group by uid) as T3
on T1.uid =T3.uid