mysql 统计不同区域下不同行业的发布数量

现有两张表,一张是基础信息。一张是关联信息。现要通过 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值,谢谢。

阅读 500
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题