Here is the query:
SELECT l1.id AS link_id,
l1.link,
l1.title,
l1.time_submitted,
(sum(i1.leaning_code)) AS interesting_weight,
(sum(p1.leaning_code)) AS political_weight
FROM tbl_link l1
LEFT OUTER
JOIN tbl_leaning_interesting i1
ON l1.id = i1.link_id
LEFT OUTER
JOIN tbl_leaning_political p1
ON l1.id = p1.link_id
GROUP BY l1.id, l1.link, l1.title, l1.time_submitted
order by l1.time_submitted desc
tbl_leaning_interesting
has 4 entries: 1 '-1' and 3 '1'. This should add up to 2 for the sum column, but I am getting 8. Any idea why this is? Thank you for any help.