当前位置:首页 > IT技术 > 数据库 > 正文

mysql里面的count函数连表查询某个字段在另一张表的数量
2022-05-29 22:33:48

select c.*,
(select count(hcus.id) from hcus where c.id=hcus.id and study_status='finished') as learnStuNum,
(select count(hcus.id) from hcus where c.id=id ) as learnNum
from c
where c.id=#{id}

本文摘自 :https://www.cnblogs.com/

开通会员,享受整站包年服务立即开通 >