mysql关联外键
select a.id,a.name,
sum(case when d.status=0 then 1 else 0 end) as 待处理,
sum(case when d.status=1 then 1 else 0 end) as 带跟进,
sum(case when d.status=2 then 1 else 0 end) as 已结束,
sum(case when d.status=3 then 1 else 0 end) as 已完成
from d d,a a
where a.id = d.aid (d表的aid和a表的id对应,但d表有多条数据的aid=a.id)
group by a.id
select a.id,a.name as 处理人,c.name as 所属机构
from A a,B b,C c
where a.id = b.Aid and c.id = b.Cid (B表是中间表,只存放a表的ID和c表的ID)
就是把这两个sql语句写在一个里面
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号