现有两张表,一张是基础信息。一张是关联信息。现要通过 t2.country_id
条件值进行查询,不同区域下的各自行业industry_id
的总数量。
select t1.*,t2.country_id from (
select count(*) as talent_count,a.talent_id,a.company_id,a.offer_import_country,a.industry_id,b.industry_name
from hb_offer_activity_talent as a
LEFT JOIN hb_company_industry as b on (a.industry_id=b.industry_id)
where a.activity_id=1001
GROUP BY a.industry_id ) as t1 left join hb_offer_activity_talent_be as t2 on (t1.talent_id=t2.talent_id)
where t2.country_id in (1001,1002) ORDER BY t2.country_id asc;
如下图的取出值,但是 talent_count
的数量不正确,原因是子查询没有指定 whereIn t2.country_id
的值。
请教各位老师,如何能查询正确talent_count
值,谢谢。