You can't do this in one query (at least not on mysql).

You'll need to fetch a list of message_idnr to delete (1) and then
delete the messages (2).

1)
select message_idnr from dbmail_messages m
  join dbmail_physmessage p on m.physmessage_id=p.id
  join dbmail_mailboxes b on m.mailbox_idnr=b.mailbox_idnr
  join dbmail_users u on b.owner_idnr=u.user_idnr
where
   userid='testuser1' and
   b.name='INBOX' and
   p.internal_date < '2011-01-01';

2)
delete from dbmail_messages where message_idnr in (xxx);




On 10/31/2010 12:07 PM, Jorge Bastos wrote:
> Howdy Paul / others,
> 
>  
> 
> I’m trying to achieve one thing that is:
> 
>  
> 
> Delete email on INBOX only, emails older than a specified date, example:
> 
>  
> 
> ·         Delete emails on INBOX older than 31-07-2010
> 
>  
> 
> How could this be done?
> 
> I have no idea.
> 
>  
> 
> Thanks,
> 
> Jorge,
> 
> 
> 
> _______________________________________________
> Dbmail-dev mailing list
> Dbmail-dev@dbmail.org
> http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev


-- 
  ________________________________________________________________
  Paul Stevens                                      paul at nfg.nl
  NET FACILITIES GROUP                     GPG/PGP: 1024D/11F8CD31
  The Netherlands________________________________http://www.nfg.nl
_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev

Reply via email to