Multiple mysql joins causing issue with query -
i'm using following query filter , score results assigned categories working right now. however, if try join, able factor in tag matches scoring, run in issue lots of results returned aren't assigned 3 categories.
here's 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 ) score results inner join categories c on results.id = c.result_id c.name in ('refinance', 'condo', 'usda') , ( results.scope = 'all' or results.scope = 'hi' ) , published = 1 group results.id having count(c.c_id) = 3 order score desc limit 8 offset 0
adding following line below categories results, what's giving me problems
inner join tags on results.id = tags.result_id
it's if following line stops working when add 2nd join
having count(c.c_id) = 3
i'm @ loss here , appreciated!
the count()
failing because have multiple rows in new join matching original data. count()
counts non-null values. so, if there 2 matches per id, you'll 6 rows -- , count of 6.
i think following fix problem:
having count(distinct c.c_id) = 3