Here i have tables
1) users_interests
user_id interest_id
677 12
677 14
677 13
2) answer_points
user_id in_id point
677 12 -1
677 12 1
677 12 1
677 14 1
678 14 1
3) interests
id name
12 movie
13 cooking
14 music
here what i want to do is,I want output like this
interest_id name point
12 movie 1
13 cooking 0
14 music 1
Where user_id=677
I tried this query
select ui.interest_id,i.name,sum(a.answer_points) as total from
users_interests as ui inner join interests as i on i.id=ui.interest_id
left join answer_points as a on a.in_id=ui.interest_id
where i.user_id='677' group by a.in_id
But its not counting 1 vote. it returns 3 total for movie