Fetch record from 3 tables which are related to each other through ID
JOINing is done before COUNTing.  That is, it gets 5 (or whatever) rows after joining, but 5 is not the value you wanted.

Instead, use a subquery to get the COUNT(*).