Is it possible to combine these two queries?

Given the application I’m working on, it will simplify things greatly if these two queries can be combined. Is this possible?

query 1:
Select organization_name, email from partners

query 2:
SELECT count(*) as ‘referrals’ ,partner_id
FROM partner_application_stories
GROUP BY partner_id

desired output:

organization_name | email | referrals

Thanks E

I am on my phone now, but if your partners table has a partner_id then you can do something like:


SELECT
  p.organization_name 
  , p.email
  , (SELECT
    count(*) 
     FROM
       partner_application_stories) AS 'referrals'
  , pas.partner_id
FROM
  partners AS p
INNER JOIN // Returns only matching rows if you want all rows in the p.partner table use LEFT OUTER JOIN or all in right the RIGHT OUTER JOIN
  partner_application_stories AS 'pas'
  ON p.partner_id = pas.partner_id
GROUP BY pas.partner_id

I won’t be at a computer until tomorrow, but give this a try and see if it works for you.

Regards,
Steve