I got two tables with mails: One table contains the meta-information of an email-conversation like participants, title, ...
Conversations:
id - title
The second table contains the attached messages, which are joined via conversation-id:
Messages:
id - conversationid - date
Now I would like to get the id of all conversations where the last attached message is older than 2 days.
I created this:
SELECT max(c.date) as lastanswer, t.id
FROM daf64_bestia_mails as m
LEFT JOIN daf64_bestia_mails_messages AS c ON c.conversationid=t.conversationid
WHERE t.state = 0
Now if I try to get
AND lastanswer > 2015-07-19
I get an error that tells me, that lastanswer is not known.
How can I create a correct query here?