I'm using the following query to filter and score results which are assigned to certain categories which is working perfectly right now. However, if I try to do another join, to be able to factor in tag matches to the scoring, I run in to an issue where lots of results are returned which aren't assigned to the 3 categories.
Here's the working query...
SELECT DISTINCT results.*,
(
3*(MATCH(body) AGAINST('*' IN BOOLEAN MODE)) +
5*(MATCH(title) AGAINST('*' IN BOOLEAN MODE)) +
1*usefulness +
30*(MATCH(body) AGAINST('""' IN BOOLEAN MODE)) +
20*(MATCH(title) AGAINST('""' IN BOOLEAN MODE)) +
5*shares
) AS score
FROM results
INNER JOIN categories c on results.ID = c.RESULT_ID
WHERE c.name in ('refinance', 'condo', 'usda')
AND ( results.scope = 'all' OR results.scope = 'hi' )
AND published = 1
GROUP BY results.ID
HAVING COUNT(c.c_ID) = 3
ORDER BY score DESC
LIMIT 8 OFFSET 0
Adding the following line below the categories results, is what's giving me problems
INNER JOIN tags ON results.id = tags.result_id
It's as if the following line stops working when I add the 2nd join
HAVING COUNT(c.c_ID) = 3
I'm at a loss here and any help would be greatly appreciated!