The query executes as expected when I write:
SELECT id, day2.count - day1.count AS diff
FROM day1 NATURAL JOIN day2;
But what I really want is a right join. When I write,
SELECT T1.id, day2.count - day1.count AS diff
FROM day1 RIGHT JOIN day2 AS T1
ON day1.id = day2.id
It says that it can't recognize day2.count in the fields list. (Also, I don't know if it should be RIGHT OUTER JOIN in the second query, but the result is the same in this case.)
I feel like I'm missing something simple.
EDIT: Here are the definitions:
day1
id bigint(8) NOT NULL
count bigint(21) NOT NULL
day2
(Same as day1)
The idea is that there might be new ids in the day2 table that were not there in day1.