[quote=“busboy, post:1, topic:202200, full:true”] Am I using the wrong type of join for this situation?[/quote]the problem is, you’re joining to two one-to-many relationships at the same time, and thereby getting cross join effects
you’ll have to do the counting in subqueries –
SELECT a.topicID
, a.topic
, b.numberOfTestimonialsAssigned
, COALESCE(c.topics,0) AS numberOfStudiesAssigned
FROM topics AS a
INNER
JOIN ( SELECT topicID
, COUNT(*) AS numberOfTestimonialsAssigned
FROM testimonialtopics
GROUP
BY topicID ) AS b
ON b.topicID = a.topicID
AND b.numberOfTestimonialsAssigned > 0
LEFT OUTER
JOIN ( SELECT topicID
, COUNT(*) AS topics
FROM studytopics
GROUP
BY topicID ) AS c
ON c.topicID = a.topicID