I have 2 tables holding statistical data. The clicks (field "homepage_click") in both tables concerning the company with the id=1 should be summed up to one value.
Table clicks:
id_firmendaten homepage_click
1 5
Table clicks_month:
id_firmendaten homepage_click
1 3
1 1
This is my MySQL-statement:
Code: Select all
SELECT SUM( t1.homepage_click + t2.homepage_click ) AS homepage_click
FROM clicks AS t1
JOIN clicks_month AS t2 ON t1.id_firmendaten = t2.id_firmendaten
WHERE t1.id_firmendaten =1That is obviously _incorrect_, here homepage_click = 9 would be the correct result.
What am I doing wrong? I would like to avoid any PHP coding and have MySQL do the addition of the values in both tables.
Thanks for your help,
visionmaster