Hello everyone,
I have tried to solve this problem, but can't. Basically, I want to get rid of messages that have expired (or aren't "saved") in a few queries, but with the table structure I have, I can't seem to figure out how.
Here's my db structure:
conversations -
conversation_id (auto_incremented, primary key)
expirationdate (timestamp)
saved (integer, 0 or 1)
//other fields you don't need to know
messages
conversation_id
message text
If it wasn't clear before, I want to delete messages that their corresponding conversation has reached it's expiration date has expired. I was thinking about a query like:
DELETE FROM messages, conversations WHERE messages.conversation_id = conversations.conversation_id AND conversations.expirationdate < NOW() AND conversations.saved = 0
But that doesn't really make sense, and it gives me an error when trying to do it. (BTW, anyone have an easy to read tutorial on JOINs?)
So, any help would be appreciated. Feel free to modify the table structure, if necessary.
Many thanks