I want to update my table visitors once an hour based on the count() from another table called sessions.
The code I have so far:
UPDATE visitors
INNER JOIN sessions
on visitors.visitor_ID = sessions.visitor_ID
SET visitors.last_30_day_sessions = (select count(sessions.session_ID)
where sessions.session_timestamp >= NOW() - INTERVAL 30 DAY)
It seems to be doing something but the numbers don't match when I simply check the number of sessions the visitor actually made in the past 30 days.
FROMclause