Hi folks,
This will be simple for the experts, I hope. I have two tables,
one of which, "A" has an ID field, and another of which, "B" is a
join table which references A.ID.
I want to delete from "A" all items which are not currently
represented in B. I could use this SQL I think, but I'm conscious
of how SLOOOOOOW it would be, because the second query is
going to be run for EVERY row in A. Can anyone propose a more
efficient formulation please?
delete from A
where ID not in
(select A.ID from A, B
where B.A_ID=A.ID)
cheers,
peter
============================================
Peter Hyde, SPIS Ltd, Christchurch, New Zealand
* Print-to-Web automation http://TurboPress.com
* Web design, automation and hosting specialists
* TurboNote: http://TurboPress.com/tbnote.htm
-- small, FREE and very handy
Find all the above and MORE at http://www.spis.co.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz