Subject | Delete from two tables at once |
---|---|
Author | Robert Munro |
Post date | 2003-04-30T13:00:39Z |
I have to tables (A and B), and I want to delete records from both of
them that exist in both of them. If a record exists in only one, then
I don't want to delete it.
This would be the easiest way to do it:
delete from A where id in (select id from B)
The problem is that after I delete them table A, I loose my record of
what to delete from B, so I can't follow up with:
delete from B where id in (select id from A)
as the records have already gone.
Any suggestions?
Robert Munro
them that exist in both of them. If a record exists in only one, then
I don't want to delete it.
This would be the easiest way to do it:
delete from A where id in (select id from B)
The problem is that after I delete them table A, I loose my record of
what to delete from B, so I can't follow up with:
delete from B where id in (select id from A)
as the records have already gone.
Any suggestions?
Robert Munro