Forum Moderators: open
newsid ¦ userid ¦ score
4 ¦ 2 ¦ 1
4 ¦ 3 ¦ -1
4 ¦ 4 ¦ -1
4 ¦ 5 ¦ -1
If I do this query:
SELECT SUM(score) FROM votes WHERE newsid = 4
It correctly gives me -2. But I have a main query using INNER JOIN which looks like this:
SELECT news.*, SUM(votes.score) AS score, users.username AS username FROM news INNER JOIN votes ON news.id = votes.newsid INNER JOIN users ON news.userid = users.id WHERE score >= 1 GROUP BY news.id ORDER BY news.id DESC
And this tells me score = 1, not -2. Any help would be appreciated.