My head hurts.
Can you *START* by showing us your DB schema for the three tables? I don't even know which fields are coming from which tables.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.