What version of MySQL are you using?
Ver 4.1 supports sub-queries.
So, you may issue:
    DELETE FROM table2
    WHERE msg_id IN(
        SELECT msg_id FROM table1
        WHERE ((TO_DAYS(NOW()) - TO_DAYS(date_column)) > 45)
    )


Thanks
Emery
----- Original Message -----
From: "Luis Lebron" <[EMAIL PROTECTED]>
To: "Mysql (E-mail)" <[EMAIL PROTECTED]>
Sent: Wednesday, October 29, 2003 20:05
Subject: Deleting from multiple tables
> I am working on some database tables to handle messages on an intranet.
> One table looks like this
> msg_id | subject | message | date
>
> there is another table used to track senders and recipients that looks
like this
> msg_id | sender_id | recipient_id |
>
> Now what I would like to do is delete any messages that are older than 45
> days and the corresponding records in the second table.
>
> How can I delete matching records from both tables at the same time?
>
>
> thanks,
>
>
> Luis R. Lebron
> Project Manager
> Sigmatech, Inc
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to