March 6, 2004 at 7:59 am
Is there a better way to delete records from one table where not in another table than
DELETE FROM stagingin
WHERE id1 + id2 + id3
NOT IN (select id1 + id2 + id3
from plans)
March 7, 2004 at 3:57 pm
How about...
delete S
from
stagingin S
left join plans P on P.id=s.id
where
P.id is null
Cheers,
Kevin
March 8, 2004 at 9:58 am
The left join is the preferred method.
March 9, 2004 at 5:27 am
If you have any indexes on the ID columns, this will probably be fastest:
DELETE FROM StagingIn
WHERE NOT EXISTS
(SELECT *
FROM Plans
WHERE ID1 = StagingIn.ID1
AND ID2 = StagingIn.ID2
AND ID3 = StagingIn.ID3)
--Jonathan
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy